Select 500000 records and write to excel sheet till all records are processed

Hi Devs, please I have up to 3 million records and I need to write them into excel sheet but the problem is job execution stops cause of the large records.We decided to select 500000 as chunk and write to excel sheet, if sheet1 is full write to next sheet till all 3 million records have been written.Please assist on the code or logic to resolve this.Regards


I assume you have 3 million rows in a datatable in that case we can use linq to split the datatable into multiple chunks. Please refer the below thread and suggestions. It might helpful for your requirement. Thanks.


Check below thread for your reference

Hope this will help you