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

后端 未结 7 1407
礼貌的吻别
礼貌的吻别 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:19

    Interop is inherently very slow. There is a large overhead associated with each call. To speed it up try writing back an object array of data to a range of cells in one assignment statement.

    Or if this is a serious problem try using one of the Managed Code Excel extensions that can read/write data using managed code via the XLL interface. (Addin Express, Managed XLL etc.)

提交回复
热议问题