We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Export to excel from data table

Hi,
I want to export data to excel from data table and also I would like to know if the he data table contains for example 100 rows, first 30 rows should display to one page remaining 70 rows should display to another page. Basically How do I use page breaker in the excel sheet object. Kindly give me sample to see the same.

Regards,
Anna

1 Reply

MW Melba Winshia Syncfusion Team October 12, 2006 05:24 AM UTC

Hi Anna,

1) Use the following code snippets to export data to excel from data table.

[C#]

//Import data table
sheet.ImportDataTable(dataTable,true,1,1,30,-1,true);

2) Here is the sample for your reference to set first 30 rows in one sheet and remaining 70 rows in other sheet.

 ImportDataTable.zip


3) Use the following code snippets to set page breaker in Excel object.

// Giving Horizontal pagebreaks
sheet.HPageBreaks.Add( sheet.Range[ "A5" ] );

// Giving Vertical pagebreaks
sheet.VPageBreaks.Add( sheet.Range[ "B5" ] );

Here is the sample for your reference:

PageBreak.zip


Please take a look and let me know if you have any other questions.

Thanks,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon