I try to copy the contents of a sheet to a new sheet in the same workbook, but the merged cells are not copied, so I try to manually copy them.
The problem is, that when I open the resulting xlsx-file, Excel tells me that there is unreadable data in the file and if it should correct them. Once corrected, the file is OK, but I cannot produce a valid file this way.
This is the code I use to copy the merged cells:
Code: Select all
for i := 0 to AXls.Sheets[ASourceSheetNr].MergedCells.Count - 1 do
begin
oMergedCell := AXls.Sheets[ADestSheetNr].MergedCells.Add;
oMergedCell.Assign(AXls.Sheets[ASourceSheetNr].MergedCells.Items[i]);
end;
Greetings
MLG