Hello Support,
I’m wondering what’s the best way to deal with merged cells and copy-paste operations. Actually I’m trying to copy a “standard” column with values inside a “merged” column where every row contains merged cells. In images: this is the source https://i.imgur.com/iO6HkTz.png , this is the destination https://i.imgur.com/1jiGAN8.png and this is what I’m expecting https://i.imgur.com/xpM4yqt.png .
This is what I’ve got https://i.imgur.com/jmNLBNn.png . Please notice that involved cells are correctly merged but the visualization is remarcable. This is the code I’ve wrote:
Workbook source = new Workbook(Path.Combine(Path.GetDirectoryName(location), "Source.xlsx"));
Workbook workbook = new Workbook(Path.Combine(Path.GetDirectoryName(location), "Destination.xlsx"));
Worksheet ws = workbook.Worksheets[0];
for (int i = 0; i < 50; i++) //creating 50 merged cells
{
var r = ws.Cells.CreateRange(i, 0, 1, 2);
r.Merge();
}
Aspose.Cells.Range sourceRange = source.Worksheets[0].Cells.CreateRange(1,0,10,1); //getting 10 rows of first column
Aspose.Cells.Range destRange = ws.Cells.CreateRange(3,0, 10, 1); //using 10 rows of destination sheet
PasteOptions options = new PasteOptions();
options.PasteType = PasteType.All;
destRange.Copy(sourceRange, options); //copying the data
workbook.Save(Path.Combine(Path.GetDirectoryName(location), "result.xlsx"));
Please let me know where I’m wrong. Best regards