You need to sign in to do that
Don't have an account?
VisualForce page to output TAB DELIMITED Data
I have created a VF page and controller apex as follows:
The Apex Class....
public class GenPortableFAData
{
public GenPortableFAData(ApexPages.StandardController controller) {
}
public Fixed_Asset__c[] getGenPortableFAData()
{
string CId;
CId = ApexPages.CurrentPage().getParameters().get('id');
Configuration__c [] CFList;
Fixed_Asset__c [] FAList;
CFList = [select Configuration__c.Id from Configuration__c where Configuration__c.Id = :CId];
FAList = [select Fixed_Asset__c.Id, Fixed_Asset__c.Asset_Tag__c,
Fixed_Asset__c.Description__c, Fixed_Asset__c.Location_Info__c, Fixed_Asset__c.Condition__c
from Fixed_Asset__c where AcctSol__Fixed_Asset__c.Configuration__r.Id = :CId];
return FAList;
}
}
The VF Page:
<apex:page standardController="Configuration__c" extensions="GenPortableFAData" contentType="text/tab-separated-values#S01_Data.txt">
<apex:repeat value="{!GenPortableFAData}" var="fixedasset">
{!fixedasset.Id}{!fixedasset.Asset_Tag__c}{!fixedasset.Description__c}{!fixedasset.Location_Info__c}{!fixedasset.Condition__c}
</apex:repeat>
</apex:page>
It is working fine in that the records that I want to appear are appearing - it is creating the text file with the name I provided and it's all good... somewhat.
But I have a few problems....
1. I need the columns to be delimited by TABs and I don't know what contentType to use ?
2. The output file contains a single blank line at the top of the file and then the data records - how do I lose the blank line ?
3. I need to add a last column for each record that is the current system date/time (e.g System.today()) ?
Any assistance that you could provide would be GREATLY appreciated !!
The Newest of Newbies
AngiB
1) Use "text/plain" or "text/tab-separated-values" (preferred).
2) Probably due to how you're writing the code. Try this:
No line breaks at all in the page; add them in your code instead of using apex:repeat.
3) Again, do this in code. Unless you exceed 1mb of data, it should work just fine.
All Answers
1) Use "text/plain" or "text/tab-separated-values" (preferred).
2) Probably due to how you're writing the code. Try this:
No line breaks at all in the page; add them in your code instead of using apex:repeat.
3) Again, do this in code. Unless you exceed 1mb of data, it should work just fine.
Hi sfdcfox,
Thank you for your post it helped me to generate a text data, but however , I'm not able to generate a tab delimited text file.
Below is my Vf code:
<apex:page action="{!getTxtfileData}" controller="DownloadDataController" sidebar="false" contentType="text/tab-separated-values">
{!TextFileData}
</apex:page>
//My Controller Code to prepare a data String with tab and new line code added in:
TextFileData = TextFileData + Account.Name + '\t';
TextFileData = TextFileData + Account.Street + '\t';
TextFileData = TextFileData + Account.city + '\t'; //added tabs
TextFileData = TextFileData + '\n'; //added line break
Please let me know change which I've to make.