My C# code concatenates data of two excel files - "file" and "finalFilePath". As a result, the final file will contain combined data in Sheet1.
- Code: Select all
Workbook finalWorkbook = new Workbook();
finalWorkbook.LoadFromFile(finalFilePath);
Worksheet finalWorkSheet = finalWorkbook.Worksheets[0];
Workbook workbook = new Workbook();
workbook.LoadFromFile(file);
Worksheet sheet = workbook.Worksheets[0];
Spire.Xls.CellRange sourceRange = sheet.AllocatedRange;
Spire.Xls.CellRange destRange;
destRange = finalWorkSheet.Range[finalWorkSheet.LastRow + 1, 1];
sourceRange.Copy(destRange,true);
The concatenated data saved properly in final xlsx file. However, when I navigate through cells, it does not show correct CellValue for any row. Instead, it shows incrementing numbers like 1, 2, 3 in CellValues of a row.
How can I copy data along with correct CellValue ?