Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed May 29, 2013 7:25 am

could you please let me know how to set number format to pivot table datafields

chaitanya
 
Posts: 12
Joined: Thu May 16, 2013 10:42 am

Wed May 29, 2013 9:03 am

Dear chaitanya,

Thanks for your inquiry.
Please refer to the code snippet below.
Code: Select all
            PivotField fieldOrderNo = pivotTable.PivotFields["OrderNo"] as PivotField;
            fieldOrderNo.Axis = AxisTypes.Row;
            fieldOrderNo.NumberFormat = "0.00";


Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Jun 04, 2013 9:08 am

Dear chaitanya,

Has this issue been resolved?
Please give us a feedback at your early convenience.

Thanks & Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Jun 04, 2013 9:46 am

Dear Amy,

thanks for your continuous support.

the code below you provided works perfectly.

but is there a possibility to set number format like pivottable.datafields[0].numberformat because I don't want to set the format immediately after creating rather I do like to set the format after all the datafields are created.

chaitanya
 
Posts: 12
Joined: Thu May 16, 2013 10:42 am

Wed Jun 05, 2013 6:27 am

Dear chaitanya,

Thanks for your feedback.
For your new issue below:
"is there a possibility to set number format like pivottable.datafields[0].numberformat?"
Yes, you could try the code below.
Code: Select all
PivotTable pivottable=sheet2.PivotTables[0];
pivottable.PivotFields[0].NumberFormat = "0.0";
pivottable.PivotFields[1].NumberFormat = "0.00";


Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Jun 07, 2013 9:01 am

Hello chaitanya,

Has the code provided by worked fine for you? Has the issue been resolved? Could you please update the thread if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.XLS