Click here to Skip to main content
15,938,218 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
I.explore.code 29-Aug-12 9:41am    
I remember doing something similar not too long ago, what i used was OpenXML processing to create Excel(xlsx) file and using Part and Package classes in .NET to generate multiple sheets. So you split your dataset in two data tables one you write in Sheet 1 and other in sheet 2. It requires a bit of hacking around these things to get it right, took me around 3 days.
StackQ 30-Aug-12 0:20am    
OK,but when u will solve this,plz help my by code.thnks..

1 solution

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!
 
Share this answer
 
v2
Comments
StackQ 30-Aug-12 0:21am    
can u guide me through code,bcoz i m a beginner.
Killzone DeathMan 2-Sep-12 15:12pm    
This days I dont have time for writing code for you... sorry!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900