Export to Excel using erializeToCSV

When I try to export the grid to excel, one of the filed which contains customer numbers like 0000237 is showing up as 239 in Excel.

Is there anything I should do in formatting the grid so that the export using         document.formstyle.csvBuffer.value=mygrid1.serializeToCSV();

will work?

Grid putting data in CSV as is, but excel may count this value as number while parsing incoming data and show it accordingly.
Unfortunately I don’t see any good solution, the column type is excel specific property, which can’t be set through CSV

This is a must requirement for me. I solved this issue using this work around. This solution may be useful to some users who are looking for similar solution.
I always set the coltype of the columns which are to be right alined as ‘ron’ and align as right and sorttype as int. with this settings, here is the function I use to export any grid…
function gridExport(mygrid)
{
    var html="";

    var numRows=mygrid.getRowsNum();
    var numCols=mygrid.getColumnsNum();
    html=html+"

";
    for(i=0;i<numCols;i++)html=html+"";
    html=html+"";

    for(i=1;i<=numRows;i++)
        {
            html=html+"";
            for(j=0;j<numCols;j++)
            {
                if(mygrid.getColType(j).strip()==“ron”    )
                        html=html+"";
            }
            html=html+"";
        }
    html=html+"
"+mygrid.getColumnLabel(i)+"
";
                else
                        html=html+"
 “;
                var txt=”";
                if(mygrid.cells(i,j).getValue()!=null)txt=mygrid.cells(i,j).getValue().toString();
                html=html+txt+"
";
    document.formstyle.csvBuffer.value=html.strip();
    document.formstyle.method=‘POST’;
    document.formstyle.action=’/ccb/jsp/csvExport.jsp’;
    document.formstyle.target=’_blank’;
    document.formstyle.submit();
    return;
}

The csvBuffer  variable contavis  an html table. This is sent to a jsp (it could be anything like php or whatever). The jsp simple dumps to the response object.

Following is my jsop to open the excel file show the exported data. The jsp can be rewritten in php or any other language using the same principle.
<%
response.setContentType(“application/vnd.ms-excel”);
String buf=request.getParameter(“csvBuffer”);
try{response.getWriter().println(buf);}catch(Exception e){}
%>

Neat !!