locked
Export literal containing a table, to excel RRS feed

  • Question

  • User-379429695 posted

    I have a function, which exports a gridview to excel.

    I have had to change my gridview, to an html table for various reasons.

    my table is generated with a Literal, as such:

     

    Literal.Text = "<table>"

         For each item in my dataset

                 Literal.Text &= "<tr>"

                 Literal.Text &= "<td>Some data here</td>"

                 Literal.Text &= "<td>More here</td>"

                 Literal.Text &= "</tr>"

         Next

    Literal.Text &= "</table>"

    I want to export this table to excel, and am not sure how exactly to reference each row (or) column (or) cell

    My current thought is something like:

         For each row as DataRow in Literal.Text

                  row.ExportThisRowToExcel

         Next

     

     

    ideas?  =]

    Tuesday, July 7, 2009 1:46 PM

Answers

  • User-1659704165 posted

    Hi,



    Response.Clear();
    Response.Buffer = true;

    string Strmyexcel ="";
    Strmyexcel ="Myexece";
    Strmyexcel  = Strmyexcel + "<My design>"



    Response.ContentType = "application/vnd.ms-excel";


    Response.Write(Strmyexcel);
    Response.End();

    Or

    http://www.codeproject.com/KB/webforms/DAtaGridExportToExcel.aspx

    http://www.codedigest.com/Articles/ASPNET/130_Export_to_Excel_in_ASPNet_20_%E2%80%93Gridview_to_Excel_DataTable_to_Excel.aspx


    Or


    U can export dataset to excel..

    http://www.dotnetspider.com/forum/164-Export-dataset-into-excel-file.aspx

    http://forums.asp.net/p/1197704/2076903.aspx#2076903

    http://www.eggheadcafe.com/community/aspnet/6/10005850/export-dataset-to-excel-i.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 8, 2009 1:53 AM