2023年10月12日 12:19:51 濤神-dev 閱讀數 1309
沒有格式要求,想快速匯出datatable資料到excel可以採用以下方式實現,開發人員在除錯過程中有時候也可以用來記錄比較。
100w的資料匯出也就1~2秒的時間。
void main()
for(int i=0;i<1000000;i++)
datatable.rows.add(dr);
} string filename="excel.csv";
stopwatch watch=new stopwatch();
watch.start();
exporttoexcel(datatable,filename);
watch.stop();
("匯出完畢,用時:"+watch.elapsed).dump();
}public static void exporttoexcel(datatable datatable,string filename,bool isopen=false)
從DataTable高效率匯出資料到Excel
首先從資料庫讀取資料到datatable,這我就不提了,大家都明白。下面直接介紹如何從datatable高效率匯出資料到excel中的方法,如下 using microsoft.office.interop.excel using system.runtime.interopservices dll...
從DataTable高效率匯出資料到Excel
首先從資料庫讀取資料到datatable,這我就不提了,大家都明白。下面直接介紹如何從datatable高效率匯出資料到excel中的方法,如下 1 using microsoft.office.interop.excel 2using system.runtime.interopservices ...
C 快速匯出DataTable到Excel檔案
專案中需要將datatable中的內容匯出到excel檔案中,採用迴圈的方式逐個cell寫資料到excel檔案中,如下 把資料表的內容匯出到excel檔案中 public static void outdatatoexcel2 system.data.datatable srcdatatable,s...