将数据从数据集中导出到多个工作表

问题描述:

我在数据库中有一个单一的数据表,其中行数大于65536,如何将我的所有数据保存为excel格式,但保存为多张工作表.
示例-
我的datatable-> dbo.MyTable,其中行大约是1048676和7列.

因此,通过C#程序,从1到65536的行应保存在工作表1中,然后再次恢复从65537到131071的行应保存在工作表2中,依此类推,直到1048676.

I have a single datatable in database where rows are greater than 65536,how can i save all my data in excel format but in multiple sheet.
example-
My datatable->dbo.MyTable where rows are about 1048676 and 7 columns.

So by C# program the rows starting from 1 to 65536 should save in sheet 1,then the remaiining rows again starting from 65537 to 131071 rows should save in sheet2 and So on till 1048676.

只需使用一个sql查询,就像这样:``SELECT * FROM TABLE LIMIT''+ i +'',65536''其中变量``i''是标志. 首先i = 0,然后执行sql查询并导出到excel,第二个i = 65536,然后导出到excel,然后i = 131072,依此类推,直到1048676!
希望您能理解!
Just use a sql query, something like this: ''SELECT * FROM TABLE LIMIT '' + i + '', 65536'' where the variable ''i'' is the flag.
First i = 0, then you do the sql query and do the export to excel, second i = 65536, and you do the export to excel, then i = 131072, and So on till 1048676!
I hope you undestand!