Hi...
I am evaluating latest version of Aspose.cells .NET and I want to copy all the comment from one workbook/worksheet to another with all font and color formatting.
Is there any way to do the same?
Thanks
Hi Haresh,
//Load source spreadsheet
var source = new Workbook(dir + “book2.xlsx”);
//Access Worksheet containing comments
var sourceSheet = source.Worksheets[0];
//Create another instance of Workbook to store the result
var destination = new Workbook();
//Access first Worksheet of the second Workbook
var destinationSheet = destination.Worksheets[0];
//Copy source Worksheet to new Workbook
destinationSheet.Copy(sourceSheet);
//Clear the contents of the copied Worksheet if you wish to copy only the comments
destinationSheet.Cells.ClearContents(0, 0, destinationSheet.Cells.MaxDataRow, destinationSheet.Cells.MaxDataColumn);
//Save Result
destination.Save(dir + “output.xlsx”);
Hi,
//Load source spreadsheet
var source = new Workbook("e:\\test2\\book2_new1.xlsx");
//Access Worksheet containing comments
var sourceSheet = source.Worksheets[0];
//Create another instance of Workbook to store the result
var destination = new Workbook();
//Access first Worksheet of the second Workbook
var destinationSheet = destination.Worksheets[0];
//Copy source Worksheet to new Workbook
destinationSheet.Copy(sourceSheet);
//Clear the contents of the copied Worksheet if you wish to copy only the comments
destinationSheet.Cells.ClearContents(0, 0, destinationSheet.Cells.MaxDataRow, destinationSheet.Cells.MaxDataColumn);
**Aspose.Cells.Drawing.ShapeCollection shapes = destinationSheet.Shapes;**
**for (int i = shapes.Count -1; i >=0; i--)**
**{**
**if (!(shapes[i].GetType().ToString() == "Aspose.Cells.Drawing.CommentShape"))**
**{**
**shapes.RemoveAt(i);**
**}**
**}**
//Save Result
destination.Save("e:\\test2\\output1.xlsx");