<changes>
<release version="3.8-beta4" date="2011-??-??">
- <action dev="poi-developers" type="add">50681 - Fixed autosizing columns beyond 255 character limit </action>
- <action dev="poi-developers" type="add">51374 - Fixed incorrect setting of lastPrinted OOXML core property </action>
+ <action dev="poi-developers" type="fix">50681 - Avoid exceptions in HSSFDataFormat.getDataFormatString() </action>
+ <action dev="poi-developers" type="fix">50681 - Fixed autosizing columns beyond 255 character limit </action>
+ <action dev="poi-developers" type="fix">51374 - Fixed incorrect setting of lastPrinted OOXML core property </action>
<action dev="poi-developers" type="add">51351 - Word to XSL-FO converter</action>
- <action dev="poi-developers" type="add">50458 - Fixed missing shapeId in XSSF drawings </action>
- <action dev="poi-developers" type="add">51339 - Fixed arithmetic rounding in formula evaluation </action>
+ <action dev="poi-developers" type="fix">50458 - Fixed missing shapeId in XSSF drawings </action>
+ <action dev="poi-developers" type="fix">51339 - Fixed arithmetic rounding in formula evaluation </action>
<action dev="poi-developers" type="add">51356 - Support autoSizeColumn in SXSSF</action>
<action dev="poi-developers" type="add">51335 - Parse picture goal and crop sizes in HWPF</action>
<action dev="poi-developers" type="add">51305 - Add sprmTCellPaddingDefault support in HWPF</action>
if (_movedBuiltins) {
return _formats.get(index);
}
-
- String fmt = _formats.get(index);
+
+ if(index == -1) {
+ // YK: formatIndex can be -1, for example, for cell in column Y in test-data/spreadsheet/45322.xls
+ // return null for those
+ return null;
+ }
+
+ String fmt = _formats.size() > index ? _formats.get(index) : null;
if (_builtinFormats.length > index && _builtinFormats[index] != null) {
// It's in the built in range
if (fmt != null) {
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.ss.usermodel.BaseTestDataFormat;
-import org.apache.poi.ss.usermodel.BuiltinFormats;
-import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellReference;
/**
* Tests for {@link HSSFDataFormat}
assertTrue(customFmtIdx >= BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX );
assertEquals("\u00a3##.00[Yellow]", dataFormat.getFormat(customFmtIdx));
}
+
+ /**
+ * Bug 51378: getDataFormatString method call crashes when reading the test file
+ */
+ public void test51378(){
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("12561-1.xls");
+ for (int i = 0; i < wb.getNumberOfSheets(); i++) {
+ HSSFSheet sheet = wb.getSheetAt(i);
+ for (Row row : sheet) {
+ for (Cell cell : row) {
+ CellStyle style = cell.getCellStyle();
+
+ String fmt = style.getDataFormatString();
+ if(fmt == null)
+ System.out.println(cell + ": " + fmt);
+ }
+ }
+ }
+ }
+
}