系统开发的需要,属性文件中是这样的一些值(从Excel中抽出来的)
A1=10
B1=20
C1=A1 + B1
(实际系统比这些公式复杂的多)
有没有Java的包,可以直接以Excel的方式分析出上面表格中的值,并具提供计算功能。也就是说,通过java可以知道A1中的值是10,B1中的值是20,C1中是一个计算公式A1 + B1,然后还可以得到C1的结果值(A1 + B1 是30,30为结果值),急!请高手指点。

解决方案 »

  1.   

    这个链接不知道对你有没有帮助:
    http://hi.baidu.com/zhufangtian/blog/item/98aa164cc5919df9d72afc95.html
    //读取表格内容。
    Cell c00 = st.getCell(0,0);

    String strc00 = c00.getContents();

    System.out.println(strc00);
    看来是可以读出已知row和col的单元格的值,那么就可以完成计算功能(有没有公式不知道,但能读出来就可以计算)。
      

  2.   

    谢谢上面朋友的回答,提供的资料也看过了,那里面的功能还没有我想要的。读取Excel中的数据和计算公式,我这面都已经实现了。现在我把读出来的这些信息放到了一个属性文件中。如这样的格式
    A1=10
    B1=20
    C1=A1 + B1
    现在想找个Java包,可以识别出这里面的各种计算公式,并计算出结果。
    继续等待中...
      

  3.   

    楼上的办法已经试过了,查到的资料都是些对excel的读写操作,都很简单。我想要的是相当于excel处理计算式的核心包,比如,有excel中各种计算式的函数,有对复杂公式的分析函数等。比如我们做一个简单的四则运算的函数,要考虑运算符的优先顺,要考虑公式的解析等。如果是excel中的运算就更复杂了。所以,希望有已经写好的包可以使用。
    继续等待中...
      

  4.   

    以前用poi好像可以支持你所说的这种操作--------------------------------------
    The POI project consists of APIs for manipulating various file formats based upon Microsoft's OLE 2 Compound Document format using pure Java. In short, you can read and write MS Excel files using Java. Soon, you'll be able to read and write Word files using Java. POI is your Java Excel solution as well as your Java Word solution. However, we have a complete API for porting other OLE 2 Compound Document formats and welcome others to participate. OLE 2 Compound Document Format based files include most Microsoft Office files such as XLS and DOC as well as MFC serialization API based file formats. As a general policy we try to collaborate as much as possible with other projects to provide this functionality. Examples include: Cocoon for which there are serializers for HSSF; Open Office.org with whom we collaborate in documenting the XLS format; and Lucene for which we'll soon have file format interpretors. When practical, we donate components directly to those projects for POI-enabling them. ------------------------------------http://jakarta.apache.org/poi/
      

  5.   

    谢谢楼上的,我去查查poi相关资料
      

  6.   

    最好从EXCEL提取的时候就应该提出计算好的值
      

  7.   

    人家问的是怎么提取公式,不是值
    POI文档里说过POI支持公式,不过不知道能不能提取EXCEL中的公式,LZ可去看看