将数据从数据集中导出到多个工作表 [英] Export data from a dataset to multiple sheet

查看:80
本文介绍了将数据从数据集中导出到多个工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有一个单一的数据表,其中行数大于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!


这篇关于将数据从数据集中导出到多个工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆