PivotTables and Tables formatting is lost in copying ranges

Hello! We are experiencing the following: while transferring styles if a cell is part of a pivot table, the style is lost. If a cell is outside a pivot table styles are transferred. In the use case attached the last sheet contains styles, while the first two do not.

Thanks a lot!

pv_styling.zip (23.9 KB)

@jose.cornado,
We have observed this scenario and logged it in our database for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
CELLSNETCORE-110 - Pivot table style is not copied while using Range.CopyStyle()

@jose.cornado,

Regarding pivot table cells range lost style/formatting in the output file (after copying range(s)), please add a line to your code segment, it will fix the issue. See the line in bold for your reference.
e.g.
Sample code:


Workbook workbook = new Workbook(fs);
workbook.Worksheets.RefreshPivotTables();
for (int i = 0; i < workbook.Worksheets.Count; i++)
{

}

Please note, you will always refresh pivot tables before copying ranges (involving pivot tables), so data and its formatting should not be lost.

Hello!

Thanks for the workaround. It certainly helps. I will use it. Notice that the source data remains unstyledpv_styling-out.zip (13.8 KB)

Best,

Jose

@jose.cornado,
Thank you for the feedback. We have observed the issue where source data remains un-styled and have noted it with the ticket for our reference.

@jose.cornado,
1: If copying range, MS Excel does not copy the PivotTable,so the style is not copied. Aspose.Cells works as MS Excel.

2: If copying value the of the range , MS Excel does not copy the Table, so the style is not copied too.

Please use Worksheet.Copy() method as the following codes:

// targetRange.CopyValue(sourceRange);
//targetRange.CopyStyle(sourceRange);
targetSheet.Copy(ws);

Let us know your feedback.

Thanks!

Best,

Jose

@jose.cornado,

You are welcome.