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
Vigneshwaran LoganathanVigneshwaran Loganathan 

Blank columns while exporting csv

Hello, 

I have a VisualForce page to Export as Csv. In this I have some columns which renders based on a Boolean value. I have added a similar code below,
<td><apex:outPutlabel value="Prioritisation ANF"  rendered="TRUE"/>  </td>
<td><apex:outPutlabel value="Classification CF"  rendered="FALSE"/>  </td>
<td><apex:outPutlabel value="Prioritisation CF"  rendered="FALSE"/>  </td>
<td><apex:outPutlabel value="Classification HBV"  rendered="TRUE"/>  </td>


When it exports, it shows Blank columns as in below screenshot. For each (Render=false) it creates a blank space. it looks fine in VisualForce page though. 

  User-added image 

Any idea to overcome this.? 

Thanks 
Vignesh

NagendraNagendra (Salesforce Developers) 
Hi Vigneswaran,

It does not work fine in Visualforce. It happens to render okay only because of the default styles, but the columns are still there. They would probably render differently in the Lighting Design System. Regardless, to fix this situation, you need to put the id elements inside the conditional render:
<apex:outputPanel rendered="false"><td>text...</td></apex:outputText>
Hope this will help with the above issue.

Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra

 
Robert Humphrey 12Robert Humphrey 12

I am not an Apex coder. But I am experiencing a similar issue where Salesforce Lightning report builder is generating blank columns when exporting in .xlsx format, generally Excel columns A and C. 

The generation of Blank columns in Excel prevents creation of a Pivot table direct from the data as presented. 

As I'm sure you're aware, Pivot tables expect all columns in the dataset to be populated.  Removal of blank columns is obviously simple to fix but it requires manual intervention, or the use of an intermediate meta data layer, both of which solutions should be unnecessary..

Is there a way, other than having to resort to coding, to prevent this from happening?  Many Thanks