Page 1 of 1

CellValues not copied with range copy

PostPosted: Thu Apr 25, 2024 4:58 am
by anil_soman
I am using FreeSpire 14.2 version

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 ?

Re: CellValues not copied with range copy

PostPosted: Thu Apr 25, 2024 6:34 am
by Abel.He
Hi,

Thanks for your inquiry.
According to the messages you provided, I tested the your code with two simple excel files and find that the final file contain correctly combined data in Sheet1.
Sorry for that I don’t understand your issue that it shows incrementing numbers like 1, 2, 3 in CellValues of a row. Could you share some screenshots to show your issue? In addition, you can use our latest commercial version (Spire.Xls for Net 14.3.3) to test this scenario.


Sincerely
Abel
E-iceblue support team