PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352841 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
53d4819628
commit
e8a78447ac
@ -62,6 +62,7 @@ package org.apache.poi.hssf.usermodel;
|
||||
import java.util.Vector;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.hssf.model.Workbook;
|
||||
import org.apache.poi.hssf.record.Record;
|
||||
@ -133,6 +134,15 @@ public class HSSFDataFormat
|
||||
public HSSFDataFormat(Workbook workbook) {
|
||||
this.workbook = workbook;
|
||||
if (builtinFormats == null) populateBuiltinFormats();
|
||||
Iterator i = workbook.getFormats().iterator();
|
||||
while (i.hasNext()) {
|
||||
FormatRecord r = (FormatRecord)i.next();
|
||||
if (formats.size() < r.getIndexCode() + 1) {
|
||||
formats.setSize(r.getIndexCode() + 1);
|
||||
}
|
||||
formats.set(r.getIndexCode(), r.getFormatString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static synchronized void populateBuiltinFormats()
|
||||
|
@ -249,12 +249,13 @@ public class TestWorkbook
|
||||
HSSFWorkbook workbook = new HSSFWorkbook(fs);
|
||||
HSSFSheet sheet = workbook.getSheetAt(0);
|
||||
HSSFDataFormat format = workbook.createDataFormat();
|
||||
HSSFCell cell =
|
||||
sheet.getRow(( short ) 0).getCell(( short ) 0);
|
||||
|
||||
assertEquals(1.25,
|
||||
sheet.getRow(( short ) 0).getCell(( short ) 0)
|
||||
.getNumericCellValue(), 1e-10);
|
||||
assertEquals(1.25,cell.getNumericCellValue(), 1e-10);
|
||||
|
||||
|
||||
assertEquals(format.getFormat("0.0"), 0xa4);
|
||||
assertEquals(format.getFormat(cell.getCellStyle().getDataFormat()), "0.0");
|
||||
stream.close();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user