Aspose.Cells. Coping row from Source file to Destination file

Please provide clarifications on Aspose.Cells.

Written some function for coping row from Source cell to Destination cell. For that tried with Cells.CopyRow method

My requirement is copy 6th row from CellSource into CellDest file 1st row.
MyCopyRowHack(cellsSource, 6, cellsDest, 1);


private void MyCopyRowHack(Cells cellsSource, int nSourceRow, Cells cellsDest, int nDestRow)
{
//Copy the row -- this is not working???
cellsDest.CopyRow(cellsSource, nSourceRow, nDestRow);
}


Below function is working without using 'CopyRow', but its lengthy method.
private void MyCopyRowHack(Cells cellsSource, int nSourceRow, Cells cellsDest, int nDestRow)
{

// copy 1 column at a time A through C
cellsDest["A" + nDestRow.ToString()].Value = cellsSource["A" + nSourceRow.ToString()].Value;
cellsDest["B" + nDestRow.ToString()].Value = cellsSource["B" + nSourceRow.ToString()].Value;
cellsDest["C" + nDestRow.ToString()].Value = cellsSource["C" + nSourceRow.ToString()].Value;
}

Hi,


I guess you have gone through the below linked technical article on the subject.
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/copying-rows-and-columns.html

Through the below source code, I have copied the 2nd row from Sheet1 of Book1.xlsx to 2nd row of Sheet2 in same workbook. Moreover, I have copied 2 rows [2nd and 3rd] from Sheet1 of Book1.xlsx to another Workbook. My input and output files are attached in an archive for your reference.

C# Source Code:

//Create a new Workbook. Open the existing excel file.

Workbook excelWorkbook = new Workbook(@“C:\temp\Book1.xlsx”);


//Get the first worksheet

Worksheet sheet1 = excelWorkbook.Worksheets[0];

//Get the second worksheet

Worksheet sheet2 = excelWorkbook.Worksheets[1];


//Copy the second row with data, formattings, images and drawing objects

//to the second row in the sheet2.

sheet2.Cells.CopyRow(sheet1.Cells, 1, 1);


//Create another workbook

Workbook newWorkbook = new Workbook();


//Get first workssheet

Worksheet newsheet1 = newWorkbook.Worksheets[0];


//Copy the second and third row to new workbook’s first worksheet

newsheet1.Cells.CopyRows(sheet1.Cells, 1, 1, 2);


//Save the excel file.

excelWorkbook.Save(@“C:\temp\CopyRow.xlsx”);


newWorkbook.Worksheets[0].AutoFitColumns();

//Save the excel file.

newWorkbook.Save(@“C:\temp\newWorbookCopyRow.xlsx”);


Thank you for your support. Issue resolved. I’m sending wrong row index 1 instead of 0.
Thanks,
HVasa.