I am using the nightly 1.9.0-dev-10022002.
This code is based line for line on code in BigExample, but it doesn't
work. I can't figure out the problem. getBuiltinFormat() is returning
the number 8, as expected. But in the XLS you only see a minus sign in
the fields with negative numbers and you don't see anything in the
others. If you look at the cell format, it says that it is a custom
format with the format being just ";;".
It is worth noting that BigExample has a bug I think that doesn't
actually demonstrate the data format usage because it tries to alternate
cell style settings but tests for (mod % 2 == 0) in both cases, so the
first style gets overwritten (lines 150 and 165).
Any help would be appreciated.
private void createCurrencyCell(HSSFWorkbook wb,
HSSFRow row,
short cellNumber,
double value) {
HSSFCell cell = row.createCell(cellNumber);
HSSFCellStyle hcs = wb.createCellStyle();
HSSFFont f = wb.createFont();
//set font 1 to 12 point type
f.setFontHeightInPoints((short) 12);
//make it black
f.setColor((short) HSSFColor.BLACK.index);
// make it bold
//arial is the default font
f.setBoldweight(f.BOLDWEIGHT_BOLD);
short format =
HSSFDataFormat.getBuiltinFormat("($#,##0.00_);[Red]($#,##0.00)");
System.out.println("Data format " + format);
hcs.setFont(f);
hcs.setDataFormat(format);
cell.setCellStyle(hcs);
cell.setCellValue(value);
}
Dennis Doubleday email: [EMAIL PROTECTED]
Right Hand Manager Software web: http://www.righthandmanager.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>