Hi,
When we merge workbooks using Copy with PasteType.All option, it is not copying all smart markers properly. Kindly suggest the right approach to merge workbooks in a single sheet.
foreach (var workBook in workbooks)
{
foreach (var workSheet in workBook.Worksheets?.Where(w => w.VisibilityType == VisibilityType.Visible))
{
Range sourceRange = workSheet.Cells.MaxDisplayRange;
Range destinationRange = _workBook.Worksheets[sheetName].Cells.CreateRange(sourceRange.FirstRow + totalRowCount, sourceRange.FirstColumn, sourceRange.RowCount, sourceRange.ColumnCount);
destinationRange.Copy(sourceRange, new PasteOptions
{
PasteType = PasteType.All
});
totalRowCount = sourceRange.RowCount + totalRowCount + 1;
}
}
}
@PramodHegde,
Could you please create a standalone VS.NET
application (runnable), zip the project and post us to show the issue, we will check it soon.
PS. please exclude Aspose.Cells.Dll to minimize the size of the zipped archive.
Thanks Amjad - Can you create a small console project and show it to me, how to merge workbooks in different sheets without losing smart markers and their cell references?
If you could share any samples, it should be fine.
My requirement is to merge multiple workbooks in different sheets without losing smart markers.
@PramodHegde,
Please refer to the document with example code on how to merge multiple worksheets to single worksheet via Range.Copy method for your reference and write your own code for your custom needs. If you still find any issue, then as requested above, kindly do share a sample (runnable) console application, we will check your code and assist you to accomplish the task. Also, provide your template Excel file(s), current output Excel file and your expected output file for reference. This will help us really to evaluate your issue precisely and to consequently figure it out soon.
Thanks Amjad for reply - But I am using the same way which you shared in your link.
Can you share any sample workbooks with smart markers and in case merge/copy is working?
destRange.Copy(sourceRange);
I can’t set up local console to share the files.
@PramodHegde,
Aspose.Cells’ Range.Copy works the same way as MS Excel does. You may even accomplish the task manually in MS Excel and then perform similar steps using Aspose.Cells APIs. We think some issue with your code. That’s why we need the resource files and sample code to trace it. You may use some dummy files in a separate console demo application and share with us to demonstrate the issue.