https://issues.apache.org/bugzilla/show_bug.cgi?id=52592

--- Comment #3 from bscart...@yahoo.com 2012-02-03 18:03:44 UTC ---
Here is a test case.  I created a worksheet and entered some numbers.
A:1 =  36,353,425 
B:1 =  456,789 

and formatted the cells as "User Defined", format (1,1234)

which means that negative numbers are displayed parentheses


The cell style format string is

_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)


public class TestDataFormatter extends TestCase  {

    private Workbook workbook;
    private DataFormatter formatter;

    protected void setUp(){
        try {
            File file = new File("contrib/numbers.xls");
            this.workbook = WorkbookFactory.create(file);
            this.formatter = new DataFormatter(); // (true);
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }

    public void testDataTypes(){
        Sheet sheet = this.workbook.getSheetAt(0);
        System.out.println("Sheet: " + sheet.getSheetName());
        int lastRowNum = sheet.getLastRowNum();
        for(int j = 0; j <= lastRowNum; j++) {
            Row row = sheet.getRow(j);
            parseRow(row);
        }
    }

    private void parseRow(Row row){
        int lastCellNum = row.getLastCellNum();
        for(int i = 0; i <= lastCellNum; i++) {
            Cell cell = row.getCell(i);
            if (cell != null){
                String val = (this.formatter.formatCellValue(cell));
                System.out.println(row.getRowNum() + ":" +
cell.getColumnIndex() + " " + val);
                if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC){
                    assertTrue (val.indexOf("*") < 0);
                }
            }
        }
    }

}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to