You need to sign in to do that
Don't have an account?
URVASHI
Export to CSV file
hi i need help
Below is my code:
VF page:
<apex:page sidebar="false" showHeader="false" controller="communityCon1234" cache="true" contentType="text/csv#Error.csv" language="en-US"> <apex:repeat value="{!HeaderXLS}" var="a"> <apex:outputText value="{!a}"> </apex:outputText> </apex:repeat> <br/> <apex:repeat value="{!fileLine}" var="b"> <apex:outputText value="{!b}"></apex:outputText> </apex:repeat> <br/> </apex:page>
Controller:
public List<String> getHeaderXLS() { List<String> listString1 = new List<String>(); listString1.add('phnnumber'); listString1.add('name'); return listString1; } public List<String> getFileLine() { List<String> listString = new List<String>(); listString.add('123456'); listString.add('urvashi'); return listString; }
MY problem here is i wana display the values of listString and listString1 in different columns in excel file.
like
phnnumber name
123456 urvashi
The the size of listString is not fixed.It varies depending upon the code.
How do i do this?
Please help.
And how do i insert<br/> tag in btwn vf page so that it doesnot come in the excel file.
I am really not sure if there is any better way to create CSV file in SFDC, but below code is working as you are expecting:
VF:
Apex:
VF:
Apex:
This is your code
GO through these post
http://boards.developerforce.com/t5/Apex-Code-Development/How-to-export-data-to-CSV-file-using-Apex/td-p/166567
http://boards.developerforce.com/t5/Apex-Code-Development/export-specific-data-from-Salesforce-to-a-csv-file/td-p/301481
Hey sonali thanks.
It helped me.
Can u futher help me,
I am using a list<list<String>> for a 2d array for writing to the file.
But it writes some extra chararcters to the file
Above is my code:
controller:
Vf page
Here when i try to write message and error
it writes with braces
[message] and [error]
can u tell me how to remove this braces.