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:
Nick Burch 2009-05-16 17:39:31 +00:00
parent eaa9c19074
commit cf0d23d3de
5 changed files with 23 additions and 1 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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;
}

Binary file not shown.

View File

@ -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;
/**
@ -268,6 +270,24 @@ public final class TestHSSFDataFormatter extends TestCase {
}
}
/**
* 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
System.out.println(msg);