+ Start a Discussion
force shahidforce shahid 

Date format is changed and 1st row & 1st column empty in csv file while downloading from vfpage

Hi,
I am trying to download csv file from vf page. But it doesn't download properly.
1st row & 1st column are empty and date format is also chnaged. If field doesn't have value then next field value populate there. How can i  solve this ?

My VF apge:
<apex:page controller="OrderReport_Class" contentType="application/octet-stream#{!fileName}.csv"  cache="true" >
     Distributorcode,OrderNumber,EffectiveDate,Location,Profit
    <apex:repeat value="{!orditem}" var="item" >
        {!item.SBCF_Distributor_Code__c},{!item.order.OrderNumber},{!item.order.EffectiveDate},{!item.SBCF_Location__c},{!item.order.SBCF_ProfitCenter__c}
    </apex:repeat>
</apex:page>

My APex Class :
public class OrderReport_Class
{
    public list<Order> ord{set;get;}
    public list<Orderitem> orditem{set;get;}
    public date startdate{set;get;}
    public date startdate1{set;get;}
    public date enddate{set;get;}
    public date enddate1{set;get;}
    public string filename{set;get;}
    public string selectedorder{set;get;}
       
    public OrderReport_Class()
    {
        startdate = system.today();
        enddate = system.today();
        enddate1 = enddate+1;
        filename = 'OrderReport';
        oilist = new List<SelectOption>();
        CSVTab = 'OSO';
        system.debug('startdate:'+startdate);
        system.debug('enddate:'+enddate);
        system.debug('enddate1:'+enddate1);
        orditem = [select SBCF_Distributor_Code__c,SBCF_Location__c,SBCF_Fixture_Family__c,SBCF_FixtureCode__c,SBQQ__OrderedQuantity__c from orderitem where order.status = 'Activated' and order.ActivatedDate >: startdate and order.ActivatedDate <:enddate1];
           system.debug('orderitem'+orditem);
        
        
    }

Thanks in advance.
Raj VakatiRaj Vakati
Try like this .. My Syntax might be wrong but this just an idea .. 

Check the Value If Not NULL take the value else add the space simply .. 
 
<apex:page controller="OrderReport_Class" contentType="application/octet-stream#{!fileName}.csv"  cache="true" >
     Distributorcode,OrderNumber,EffectiveDate,Location,Profit
    <apex:repeat value="{!orditem}" var="item" >
	{!IF(((item.SBCF_Distributor_Code__c!=NULL , '' , item.SBCF_Distributor_Code__c!=NULL)}
	
    </apex:repeat>
</apex:page>