i am trying to create a csv and succeeded in that except with a new empty row has been added on the top of the csv. The following is the visualforce page code for the generation.
Also, i need to use the same page to create csv's for 2 to 3 custom list which are more or less have similar structure. What i used is nested if's to identify which content i need to output as csv and also to create headers. Is that a right approach using nested if's to handle different csv header structures in a single page?
Any best approaches to create and download CSV?
Is there any other best approaches available to generate and download csv's apart from the one simple method given below? Experts please advice.
<apex:page StandardController="Account" extensions="OpenDocumentsController" contentType="text/csv#OSO_{!CustNo}.csv" showHeader="false" sidebar="false" standardStylesheets="false">
{!(If(CSVTab=='OSO','Order #, Document Date, Purchase Order #, Sales Org, Amount,Currency,Products',If(CSVTab=='OD','abcd','test')))}
<apex:repeat value="{!OpenSalesOrders}" var="oso" rendered="true">
{!oso.OrderNo},"{!oso.DocumentDateCSV}","{!oso.PurchaseOrderNo}","{!oso.SalesOrg}","{!oso.Amount}","{!oso.Curren}","{!oso.Product}"
</apex:repeat>
</apex:page>
Screen shot with empty line at the top: