function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
YikaYika 

Create a text format file with opportunity records with a click of a button

Hi

I am new programming in Salesforce and I have the following assignment:

 

I need to create a text file using values from an opportunity list in a very specific format when I click a button, e.g. when I click the button I have to get all the opportunities that have been created today and write this list in a text file with an specific format (Opportunity name (1 – 20) right justified, Opportunity close date (21 - 30), Opportunity amount (31 - 40) right justified.

 

Can anyone please help me on how to do it.

 

Thanks and kind regards

JitendraJitendra

Use Content type attribute in Visualforce page:

 

Example,

 

<apex:page controller="csvController" cache="true" contentType="text/csv#filename.csv" language="en-US">
"Col A","Col B","Col C","Col D"
<apex:repeat value="{!myList}" var="a">
"{!a.ColA}","{!a.ColB}","{!a.ColC}","{!a.ColD}"
</apex:repeat>
</apex:page>

 

YikaYika

Jitendra,

 

Thanks for the response, but how can I associate “myList” to a set of opportunities records? Maybe sounds very basic but I am new programming in force.com and it would be very useful if you tell me how to get the opportunity records from the database to process them in this routine.

 

Thanks a lot!!!