s***@gmail.com
2018-06-21 08:54:30 UTC
Hello everyone.
I'm trying to implement an accountancy custom data format.
I start from one of your examples but even your examples provide an different output.
It seems the grouping symbol is ignored.
Do you have any thoughts?
/**
* Using a single quote (') instead of a comma (,) as
* a number separator, eg 1000 -> 1'000
*/
@Test
public final void test55265() {
Workbook wb = new HSSFWorkbook();
DataFormatter formatter = new DataFormatter();
DataFormat fmt = wb.createDataFormat();
Sheet sheet = wb.createSheet();
Row r = sheet.createRow(0);
CellStyle cs = wb.createCellStyle();
cs.setDataFormat(fmt.getFormat("#'##0"));
Cell zero = r.createCell(0);
zero.setCellValue(0);
zero.setCellStyle(cs);
Cell sml = r.createCell(1);
sml.setCellValue(12);
sml.setCellStyle(cs);
Cell med = r.createCell(2);
med.setCellValue(1234);
med.setCellStyle(cs);
Cell lge = r.createCell(3);
lge.setCellValue(12345678);
lge.setCellStyle(cs);
assertEquals("0", formatter.formatCellValue(zero));
assertEquals("12", formatter.formatCellValue(sml));
assertEquals("1'234", formatter.formatCellValue(med));
assertEquals("12'345'678", formatter.formatCellValue(lge));
}
org.junit.ComparisonFailure:
Expected :1'234
Actual :1234
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
I'm trying to implement an accountancy custom data format.
I start from one of your examples but even your examples provide an different output.
It seems the grouping symbol is ignored.
Do you have any thoughts?
/**
* Using a single quote (') instead of a comma (,) as
* a number separator, eg 1000 -> 1'000
*/
@Test
public final void test55265() {
Workbook wb = new HSSFWorkbook();
DataFormatter formatter = new DataFormatter();
DataFormat fmt = wb.createDataFormat();
Sheet sheet = wb.createSheet();
Row r = sheet.createRow(0);
CellStyle cs = wb.createCellStyle();
cs.setDataFormat(fmt.getFormat("#'##0"));
Cell zero = r.createCell(0);
zero.setCellValue(0);
zero.setCellStyle(cs);
Cell sml = r.createCell(1);
sml.setCellValue(12);
sml.setCellStyle(cs);
Cell med = r.createCell(2);
med.setCellValue(1234);
med.setCellStyle(cs);
Cell lge = r.createCell(3);
lge.setCellValue(12345678);
lge.setCellStyle(cs);
assertEquals("0", formatter.formatCellValue(zero));
assertEquals("12", formatter.formatCellValue(sml));
assertEquals("1'234", formatter.formatCellValue(med));
assertEquals("12'345'678", formatter.formatCellValue(lge));
}
org.junit.ComparisonFailure:
Expected :1'234
Actual :1234
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org