How to speed up dumping a DataTable into an Excel worksheet?

后端 未结 7 1409
礼貌的吻别
礼貌的吻别 2020-12-15 07:37

I have the following routine that dumps a DataTable into an Excel worksheet.

    private void RenderDataTableOnXlSheet(DataTable dt, Excel.Worksheet xlWk,          


        
7条回答
  •  死守一世寂寞
    2020-12-15 08:00

    Do you have a specific requirement to go the COM automation route? If not, you have a few other options.

    1. Use the OLEDB provider to create/write to an Excel file
      http://support.microsoft.com/kb/316934

    2. Use a third party library to write to Excel. Depending on your licensing requirements there are a few options. Update: A good free library is NPOI http://npoi.codeplex.com/

    3. Write the data to a csv file, and load that into Excel

    4. Write the data as XML which can be loaded into Excel.

    5. Use the Open XML SDK
      http://www.microsoft.com/downloads/details.aspx?familyid=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en

提交回复
热议问题