Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用c#将大型数据表导出到excel 2003,而不使用excel COM_C#_Excel_Datatable_Dataset - Fatal编程技术网

使用c#将大型数据表导出到excel 2003,而不使用excel COM

使用c#将大型数据表导出到excel 2003,而不使用excel COM,c#,excel,datatable,dataset,C#,Excel,Datatable,Dataset,我有一个大于300.000行的数据表,我想将此数据表导出到excel 2003,但不使用excel COM。我用过NPOI,但它会引起内存错误。我发现第三方组件(免费)可以为每一行导出并直接写入文件,以避免内存不足。谁能帮我?谢谢。csv文件怎么样?它可以从Excel中读取。试试这个Libs。我不确定容量 您可以使用webgrid(仅在代码中)导出到excel文件。假设您正在创建一个WinForm应用程序,则必须引用System.Web库 // Create the DataGrid and

我有一个大于300.000行的数据表,我想将此数据表导出到excel 2003,但不使用excel COM。我用过NPOI,但它会引起内存错误。我发现第三方组件(免费)可以为每一行导出并直接写入文件,以避免内存不足。谁能帮我?谢谢。

csv文件怎么样?它可以从Excel中读取。

试试这个Libs。我不确定容量


  • 您可以使用webgrid(仅在代码中)导出到excel文件。假设您正在创建一个WinForm应用程序,则必须引用
    System.Web

    // Create the DataGrid and perform the databinding
    var myDataGrid = new System.Web.UI.WebControls.DataGrid();
    myDataGrid.HeaderStyle.Font.Bold = true;
    myDataGrid.DataSource = myDataTable;
    myDataGrid.DataBind();
    string myFile = "put the name here with full path.xls"
    var myFileStream = new FileStream( myFile, FileMode.Create, FileAccess.ReadWrite );
    // Render the DataGrid control to a file
    using ( var myStreamWriter = new StreamWriter( myFileStream ) )
    {     
        using (var myHtmlTextWriter = new System.Web.UI.HtmlTextWriter(myStreamWriter ))         
        {         
            myDataGrid .RenderControl( myHtmlTextWriter );     
        } 
    } 
    
    我还没有用这么多记录测试过它,所以我不知道这种记忆方式的影响

    编辑:


    请注意@Charles Williams的评论,即excel 2003有行限制

    我认为使用CSV文件是不可能的?请注意,每个excel 2003工作表有65536行限制。