I am trying to generate XML based on excel rows upload.. lets say i have 20 rows in excel including heading it has to take 19 rows into consideration and generate 4 XML files.
Below is the code i have tried..
public void PublishSACHistoryXML()
{
//Total Rows from Excel
int totalRows = 0;
DataTable TotRows = _datatable.AsEnumerable() // retriews 19 rows excluding header
.CopyToDataTable();
totalRows = TotRows.Rows.Count;
int endDataRow = 5;
int pagecount;
// int startDataRow = 1;
bool _break = false;
int fileNo = 0;
if (totalRows % endDataRow == 0)
{
pagecount = totalRows / endDataRow;
}
else
{
pagecount = (totalRows / endDataRow) + 1;
}
for (int startDataRow = 0; startDataRow < pagecount; startDataRow++)
{
DataTable SelectedRows = _datatable.AsEnumerable()
.Skip(startDataRow * endDataRow)
.Take(endDataRow)
.CopyToDataTable();
// selectedrows datatable is picking as below
row number 2-6 for first XML
row number 7-11 for second XML
row number 12-16 for third XML
row number 17-19 for fourth XML
// generate XML based on selected rows
}
Expected Output
row number 2-5 for first XML
row number 6-10 for second XML
row number 11-15 for first XML
row number 16-19 for second XML
Member
17 Points
151 Posts
XML Paging
Sep 21, 2015 03:18 PM|sreekanth.jonna|LINK
Hi,
I am trying to generate XML based on excel rows upload.. lets say i have 20 rows in excel including heading it has to take 19 rows into consideration and generate 4 XML files.
Below is the code i have tried..
Expected Output