方法如下:
public void readExcelTest(String path) throws BiffException, IOException
{
Workbook wb = Workbook.getWorkbook(new File(path));
Sheet ws = wb.getSheet(0);
Cell cell = ws.getCell(0, 0);
System.out.println(cell.getContents());
}如excel中的数据为-0.0003通过getContents方法得到就是-0,怎样能得到全值"-0.0003"?

解决方案 »

  1.   

    试一下这个:    if (cell.getType() == CellType.NUMBER){
          NumberCell n = (NumberCell) cell;
          System.out.println(getValue());
        }
      

  2.   

    谢谢1楼,问题已解决,方法如下 public void readExcelTest(String path) throws BiffException, IOException
    {

    Workbook wb = Workbook.getWorkbook(new File(path));
    Sheet ws = wb.getSheet(0);
    Cell cell = ws.getCell(0, 0);
    NumberCell n = (NumberCell) cell;

    BigDecimal bigDecimal = new BigDecimal(n.getValue());
    NumberFormat numberFormat = new DecimalFormat("#.####");
    System.out.println(numberFormat.format(bigDecimal.doubleValue()));
    }