Create multiple sheets in excel file based on records

Hi , I have an excel with 50 records in sheet 1. Now i want to take each 10 records and create a new sheets with the records in the excel file.
Can anyone of you please share the solution or logic in details .

Hi @avinashy ,

That can be achieved by converting the DataTable into a List of DataTables each containing 10 records.

But how you want to go about naming each sheet is still unclear, so I’ve given generic names followed by indexes (Sheet2, Sheet3…Sheetn)

The logic for that is detailed below →

Enumerable.Range(0,CInt(Math.Ceiling(dt_sampleData.Rows.Count()/10))).Select(Function(s) dt_sampleData.AsEnumerable.Skip(s*10).Take(10).CopyToDataTable()).ToList()

Could you give this a try and let us know if it works out for you?

SplitDataIntoSheets.xaml (7.1 KB)

Kind Regards,
Ashwin A.K