Click here to Skip to main content
15,667,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
i am exporting gridview after export the data it is in the form of text, while calculations i need to change the format.

so my problem is while exporting the data i need to change to number format. is it possible. below my code

public void xlsexport(System.Data.DataTable dtGridsource, string Filename)
    int rowIndex = -1;
    int columnIndex = -1;

    string filename = Filename;
    HttpContext.Current.Response.ContentType = "application/";
    HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename));

    HSSFWorkbook hssfworkbook;
    hssfworkbook = new HSSFWorkbook();

    ////create a entry of DocumentSummaryInformation
    DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
    dsi.Company = "Adya Wifi";
    hssfworkbook.DocumentSummaryInformation = dsi;

    ////create a entry of SummaryInformation
    SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
    si.Subject = dtGridsource.TableName.ToString();
    hssfworkbook.SummaryInformation = si;

    ISheet sheet1 = hssfworkbook.CreateSheet("Sheet1");

    IRow row = sheet1.CreateRow(0);
    for (int i = 0; i < dtGridsource.Columns.Count; i++)

    for (rowIndex = 0; rowIndex < dtGridsource.Rows.Count; rowIndex++)
        IRow row1 = sheet1.CreateRow(rowIndex + 1);
        for (columnIndex = 0; columnIndex < dtGridsource.Columns.Count; columnIndex++)

    MemoryStream file = new MemoryStream();

Updated 29-Oct-14 19:48pm
George Jonsson 30-Oct-14 1:50am    
1. Please format the code properly. (I did it for you now)
2. What is your current format and what format do you want?
3. Where in the code, exactly, do you want to do the formatting?
Laiju k 30-Oct-14 4:45am    
You can click on inside particular column and there appears an an option for text to number something like that you can select columns you try to convert.I had done it.I don't know if it is the same issue for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900