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
Rakesh MRakesh M 

list problem

Hi,

My code is not giving an expected out put,  Kindly check and update me.  Please let me know how to get the data in rows. Below is my code.

public class Campaign1 {
    public list<Account> acc{set;get;}
    public campaign1(){
       acc=[SELECT Industry,Name FROM Account WHERE Industry = 'energy'];
        for(integer i=0; i<acc.size();i++){
            System.debug(acc);
        }
        }
    }

<apex:page controller="Campaign1" cache="true" contentType="text/csv#Campaign.csv" language="en-Us" >
    <apex:repeat value="{!acc}" var="a">"{!a.name}"
    </apex:repeat>
</apex:page>
Output:
United Oil & Gas Corp."XYZ Global Services (India)"YYY Broadcasting Pvt Ltd"XXX Academy For Skill And
Expected output:-
United Oil & Gas Corp.
XXX Academy For Skill And
YYY Broadcasting Pvt Ltd
XYZ Global Services (India)
  
BALAJI CHBALAJI CH
Hi Rakesh,

Can you try to iterate the values in PageblockTable like below VF page:
<apex:page controller="Campaign1" cache="true" contentType="text/csv#Campaign.csv" language="en-Us" >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!acc}" var="a">
            <apex:column value="{!a.name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Let us know if that helps you.

Best Regards,
BALAJI
Rakesh MRakesh M
Hi Balaji,

After dealing with your code the expected output is not coming.

Thanks for having interest in my query.

Regards,
Rakesh Mungelkar.
Akshay_DhimanAkshay_Dhiman
Hi Rakesh,

Please try with this code :
<apex:page controller="Campaign1" cache="true" contentType="text/csv#Campaign.csv" language="en-Us" >
    <apex:repeat value="{!acc}" var="a">"{!a.name}" <br/>
    </apex:repeat>
</apex:page>

If it's help you, please mark my answer. 

Regards,
Akshay
Rakesh MRakesh M
Hi Akshay,

Thank you for reply.

Below is the output for your code. Still expected output has not come.

United Oil & Gas Corp.<br />"XYZ Global Services (India) Pvt."<br />"YYY Broadcasting Pvt Ltd"<br />"XXX Academy For Skill And"<br />

Regards,
Rakesh M.