Adding Sheets till specific value

Hi Guyz, hope you are doing well,
So basically I want to write 6 rows in single excel sheet, if I have more than 6 rows to write, it should be written in new sheet within the same file. E.g if I want to write 8 rows, first 6 rows should be written on Sheet1 and the remaining in Sheet2. Like wise if I have 14 rows then first 6 Rows in Sheet1, then in Sheet2 and the remaining 2 in Sheet3. What logic should I implement here?
Plz help
Thanks in advance

have a look on following links:

for the concept:

other demo

Its not adding on another sheet, will BalaReva activity of add sheet is feasible for this?

We can try with simple write range with new sheetname which will get created automatically if it is not there


You can check this xaml table.xaml (12.7 KB) for the logic to create new sheet in the excel. It is also had skip and take logic as per your scenario.

@aanandsanraj Its perfect logic. But the thing is my values are in System.Data.DataRow which I am unable to convert it in Integer.

@Daniyal_Tahir Instead data row use datatable variable. After read the excel pass the variable in that logic

Logic is same a described in the links. It is just modified to write out the Excel Sheets




NoOfSegments = Convert.ToInt32(Math.Ceiling(dtData.Rows.Count / SegmentSize))
segment = Enumerable.Range(0,NoOfSegments).ToList
RowSet = dtData.AsEnumerable.Skip(segment*SegmentSize).Take(SegmentSize).toList

Find starter Help:
SplitTable_BySegmentSize_ToTable_WriteSheet.xaml (13.0 KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.