1

I am currently setting the number format using the below code

pivotTable.getCTPivotTableDefinition().getDataFields().getDataFieldArray(0).setNumFmtId(2)

But i want to set the number format which is not there in format codes of setNumFmtId function Ex: 0.0 which is not there in formats

I can only see 0.00 but not 0.0 format in format codes.

1 Answer 1

4

The NumFmtId is either one of the BuiltinFormats Ids. The Id 2 is 0.00 and, as you see, there is no 0.0 built in format.

Or it is the Id of a custom data format. A such must be created using Workbook.createDataFormat. The Id can be got using DataFormat.getFormat.

Example:

...
DataFormat dataformat = workbook.createDataFormat();
short numFmtId = dataformat.getFormat("0.0");

pivotTable.getCTPivotTableDefinition().getDataFields().getDataFieldArray(0).setNumFmtId(numFmtId);
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.