如何使用java中的excel API读取excel中的数字数据 [英] how to read number data in excel using excel API in java

查看:271
本文介绍了如何使用java中的excel API读取excel中的数字数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于读取数据的错误,类型是使用excel API从java中的excel文件中的数字(列钱)。



excel文件中的数据是1513.2539232但是java只读1513.253。

工作簿工作簿= Workbook.getWorkbook(文件); 
工作表= workbook.getSheet( 0 );
for int row = 0 ; row< rows; row ++){
for int col = 0 ; col< cols; col ++){
sheet.getCell(col,row).getContents();
}
}





那么如何正确读取数字数据(期望是1513.2539232)?





提前感谢

解决方案

可以轻松找到这类信息阅读文档 [ ^ ]。


有一些着名的第二方库使用Microsoft文档:

http://poi.apache.org/ [ ^ ],

http ://sourceforge.net/projects/openxml4j/ [ ^ ]。



如果你是谷歌的话可能会找到更多。


如果你只能使用更新的OpenXML格式,那就是开放标准ECMA-376和ISO / IEC 29500:2008。请参阅:

http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats [< a href =http://en.wikipedia.org/wiki/Microsoft_Office_XML_formatstarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/Office_Open_XML [ ^ ],

http://www.ecma-international.org/publications/standards/Ecma-376.htm [ ^ ]。



-SA

I have an error about read data with type is number(column money) from excel file in java using excel API.

my data in excel file is 1513.2539232 but java only read 1513.253.

Workbook workbook = Workbook.getWorkbook(file);
Sheet sheet = workbook.getSheet(0);
for (int row = 0; row < rows; row++) {
    for (int col = 0; col < cols; col++) {
        sheet.getCell(col, row).getContents();
    }
}



So how to I can read number data correctly(expect is 1513.2539232)?


thanks in advance

解决方案

This sort of information can easily be found by reading the documentation[^].


There are some well-known 2rd-party libraries working with Microsoft documents:
http://poi.apache.org/[^],
http://sourceforge.net/projects/openxml4j/[^].

Probably you could find some more if you Google for it.

It would be much better if you could work only with the newer OpenXML formats, which is the open standards ECMA-376 and ISO/IEC 29500:2008. Please see:
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML[^],
http://www.ecma-international.org/publications/standards/Ecma-376.htm[^].

—SA


这篇关于如何使用java中的excel API读取excel中的数字数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆