Fix bug #47154 - Handle the cell format @ as the same as General
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@775500 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eaa9c19074
commit
cf0d23d3de
@ -37,6 +37,7 @@
|
||||
|
||||
<!-- Don't forget to update status.xml too! -->
|
||||
<release version="3.5-beta6" date="2009-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="fix">47154 - Handle the cell format @ as the same as General</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">47048 - Fixed evaluation of defined names with the 'complex' flag set</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">46953 - More tweaks to PageSettingsBlock parsing logic in Sheet constructor</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">47089 - Fixed XSSFWorkbook.createSheet to properly increment sheetId</action>
|
||||
|
@ -34,6 +34,7 @@
|
||||
<!-- Don't forget to update changes.xml too! -->
|
||||
<changes>
|
||||
<release version="3.5-beta6" date="2009-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="fix">47154 - Handle the cell format @ as the same as General</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">47048 - Fixed evaluation of defined names with the 'complex' flag set</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">46953 - More tweaks to PageSettingsBlock parsing logic in Sheet constructor</action>
|
||||
<action dev="POI-DEVELOPERS" type="fix">47089 - Fixed XSSFWorkbook.createSheet to properly increment sheetId</action>
|
||||
|
@ -147,7 +147,7 @@ public class DataFormatter {
|
||||
if (format != null) {
|
||||
return format;
|
||||
}
|
||||
if (formatStr.equals("General")) {
|
||||
if (formatStr.equals("General") || formatStr.equals("@")) {
|
||||
if (DataFormatter.isWholeNumber(cellValue)) {
|
||||
return generalWholeNumFormat;
|
||||
}
|
||||
|
BIN
src/testcases/org/apache/poi/hssf/data/47154.xls
Normal file
BIN
src/testcases/org/apache/poi/hssf/data/47154.xls
Normal file
Binary file not shown.
@ -21,6 +21,8 @@ import java.text.DecimalFormat;
|
||||
import java.text.Format;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
@ -267,6 +269,24 @@ public final class TestHSSFDataFormatter extends TestCase {
|
||||
assertTrue(formatter.formatCellValue(cell).endsWith(" USD"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A format of "@" means use the general format
|
||||
*/
|
||||
public void testGeneralAtFormat() {
|
||||
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("47154.xls");
|
||||
HSSFSheet sheet = workbook.getSheetAt(0);
|
||||
HSSFRow row = sheet.getRow(0);
|
||||
HSSFCell cellA1 = row.getCell(0);
|
||||
|
||||
assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cellA1.getCellType());
|
||||
assertEquals(2345.0, cellA1.getNumericCellValue(), 0.0001);
|
||||
assertEquals("@", cellA1.getCellStyle().getDataFormatString());
|
||||
|
||||
HSSFDataFormatter f = new HSSFDataFormatter();
|
||||
|
||||
assertEquals("2345", f.formatCellValue(cellA1));
|
||||
}
|
||||
|
||||
private static void log(String msg) {
|
||||
if (false) { // successful tests should be silent
|
||||
|
Loading…
Reference in New Issue
Block a user