Free Support Forum - aspose.com

Show Grand Total Row as Bold (Pivot Table)

Dear Sir,
I have created a pivot table using coding in c#. Please find attached the excel sheet in which pivot table is created. I want to know how can i style the grand total and top row such as to make it similar to the one in next sheet(with excel) i.e. i want to make it “Bold”. Also can you suggest how I can show/format the numbers in the same way as shown in this sheet i.e. currency symbol with brackets.
I would be much obliged if you can help me out in this. Though i have a licence of previous version but here in this case i have downloaded your latest version to check if it meets my requirement and if so then we can purchase this version.
Thank you,
Radha
p.s there would be 10 pivot table on this sheet and i have to apply the style on all of them.

Hi,


I think you may try the following sample code, please refer to the code segment below for your reference. I have tested the code with your attached file and it works fine. The pivot table in the first worksheet would be same as per your second sheet.

Sample code:

string path = @“e:\test2\test.xlsx”;
Workbook workbook = new Workbook(path);
Worksheet worksheet = workbook.Worksheets[0];
PivotTable pvtTable = worksheet.PivotTables[0];
pvtTable.IsAutoFormat = true;
pvtTable.PivotTableStyleType = PivotTableStyleType.PivotTableStyleLight16;
Style style = workbook.CreateStyle();
style.Custom = “$#,##0.00_);Red”;
pvtTable.FormatAll(style);
workbook.Save(path + “.out.xlsx”, SaveFormat.Xlsx);

Thank you.

Wow, it worked like a charm. Thanks a lot!!
I was wondering if i want to put “-” for cells where there is no entry then what changes i have to make in this number format style:
pvtTable.DataFields[0].NumberFormat = “#,##0.0”;

Thank you once again, appreciate it!

Best regards,
Radha


Hi,

Good to know that your issue is resolved now.

radhashym:
I was wondering if i want to put "-" for cells where there is no entry then what changes i have to make in this number format style:
pvtTable.DataFields[0].NumberFormat = "#,##0.0";

The better way is to manually apply the number formatting for the data cells in MS Excel if it works and then get its Custom formatting string and specify it for NumberFormat attribute (for Aspose.Cells APIs) accordingly.

Thank you.