diff options
author | Nick Burch <nick@apache.org> | 2011-01-20 13:20:24 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2011-01-20 13:20:24 +0000 |
commit | aad9e6907d4ef1897ef8e05917ca476728f8e8e0 (patch) | |
tree | 41c8a4b2e1adad7429a2883586aa99a49833be0b /src/java/org/apache/poi/hssf/model | |
parent | ddf6cf7fec44416b8fb1dd8ac6b5913c32edfe40 (diff) | |
download | poi-aad9e6907d4ef1897ef8e05917ca476728f8e8e0.tar.gz poi-aad9e6907d4ef1897ef8e05917ca476728f8e8e0.zip |
Fix bug #49928 for HSSF too - refactor HSSFDataFormat to allow overriding of built in formats, and tweak the format unit tests to do the same check for HSSF and XSSF. Also corrects some builtin formats for new HSSFWorkbooks which were slightly off
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1061288 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf/model')
-rw-r--r-- | src/java/org/apache/poi/hssf/model/InternalWorkbook.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java index 12bd39d633..62796a62f2 100644 --- a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java +++ b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java @@ -88,6 +88,7 @@ import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalName; import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheet; +import org.apache.poi.ss.usermodel.BuiltinFormats; import org.apache.poi.util.Internal; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; @@ -1284,15 +1285,16 @@ public final class InternalWorkbook { // we'll need multiple editions for // the different formats + switch (id) { - case 0: return new FormatRecord(5, "\"$\"#,##0_);\\(\"$\"#,##0\\)"); - case 1: return new FormatRecord(6, "\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)"); - case 2: return new FormatRecord(7, "\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)"); - case 3: return new FormatRecord(8, "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)"); - case 4: return new FormatRecord(0x2a, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)"); - case 5: return new FormatRecord(0x29, "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)"); - case 6: return new FormatRecord(0x2c, "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)"); - case 7: return new FormatRecord(0x2b, "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)"); + case 0: return new FormatRecord(5, BuiltinFormats.getBuiltinFormat(5)); + case 1: return new FormatRecord(6, BuiltinFormats.getBuiltinFormat(6)); + case 2: return new FormatRecord(7, BuiltinFormats.getBuiltinFormat(7)); + case 3: return new FormatRecord(8, BuiltinFormats.getBuiltinFormat(8)); + case 4: return new FormatRecord(0x2a, BuiltinFormats.getBuiltinFormat(0x2a)); + case 5: return new FormatRecord(0x29, BuiltinFormats.getBuiltinFormat(0x29)); + case 6: return new FormatRecord(0x2c, BuiltinFormats.getBuiltinFormat(0x2c)); + case 7: return new FormatRecord(0x2b, BuiltinFormats.getBuiltinFormat(0x2b)); } throw new IllegalArgumentException("Unexpected id " + id); } |