应用poi

   最近答应帮友人完成一微型应用软件,主要功能将xsl数据倒入数据库,并实现报表打印。

   在数据倒入功能上决定采用poi开源项目的hssp子项目,通过hssp类读取xsl数据,并存入数据库库中。

   计划2~7天时间完成poi的学习及应用。

   特立此目标以作记录!

7 thoughts on “应用poi”

  1. 这几天抽空浏览了一下hssf的userguad 感觉对于org.apache.poi.hssf.usermodel

    提供的高层封装使用还是很方便。晚上写了个打开xsl文件的例子

    打印了一下sheet.getPhysicalNumberOfRows() 该方法Returns the number of phsyically defined rows (NOT the number of rows in the sheet)实在不明白excel里此row和比row有什么区别,埃!最想的得到列数竟然也找不到

    get方法。

    一下为测试代码,侧后将只改动read()方法, 有兴趣者可以试一试

    import java.io.*;

    import java.util.*;

    import org.apache.poi.hssf.usermodel.*;

    import org.apache.poi.hssf.model.*;

    import org.apache.poi.poifs.filesystem.*;

    /**

    *   athor :linzc

    *   time : 2004.11.19 

    *   description: this class is writed for test hssf!

    **/

    public class readpoi

    {

        private String xslfile;

        /**

        *param @string: the file name of xsl file

        **/

        public readpoi(String file)

        {

            this.xslfile=file;

        }

        /**

        *   the function is used for reading xsl file and print out the

        *   information of poifile

        **/

        public void read()

        {

           POIFSFileSystem fs=null;

            HSSFWorkbook   wb=null;

           try

           {

               fs =new POIFSFileSystem(new FileInputStream(xslfile));

          

                wb= new HSSFWorkbook(fs);

            }catch(IOException e)

           {

               System.out.println("io exception :"+e);

           }

            HSSFSheet sheet = wb.getSheetAt(0);

            //

            System.out.println("the sheet name of  poifile="+wb.getSheetName(0));

            int num=sheet.getPhysicalNumberOfRows();

            System.out.println("the physical Number of rows="+num);

           

        }

        /**

        *   the main function is ursed for testing the read funciton!

        **/

        public static void main(String[] args)

        {

            readpoi poitest=new readpoi("d:\\test.xls");

            poitest.read();

        }

    }

  2. 奇怪看不着我写的日记阿 !  只好把帖子加到评论里了:( 

    埃,点击相关日记,怎么没发新更新,不同步吗! 

    呵呵   下来该做什么了  应该连接数据库了  

    晚上在莱 现在游戏

  3.     正常情况如果写了日记并提交后,您在相关目标写的日记数就会加1,点击“相关日记”就会出现您的相应目标的日记列表。

    您的“ print 内容”日记已经提交成功了。http://www.learndiary.com/toDiaryAction.do?goalID=487(您的这个目标下的日记列表),http://www.learndiary.com/disDiaryContentAction.do?goalID=492(您的当天日记内容)。

        我把您在目标下的评论中的重复的日记删除了。

        您遇到的不同步的问题也许是本系统的一个潜在的bug,我们会认真测试的。

        对这个问题对您造成使用的不便表示报歉。

        如有任何使用上的问题请随时告知,谢谢!祝周末愉快!

  4.   thank you for your help! 我想如果有更据提示性的方法,找到自己写过的日记,会更好的:)

  5. 我前一阵子做过excel的解析,用的是JXL,感觉JXL虽然很好用,但是太简单,不知道POI怎样。自己觉得jakarta的项目应该比个人开发的开源软件更可靠,主要是后续版本的推出和文档支持等等,天知道andykhan在yahoo上开FAQ会不会有一天觉得烦,或者是他哪天翘了(上帝保佑andykhan)。所以一直想转到POI上,但是项目已经投入使用,也没什么问题,所以找不到借口去重写。

Comments are closed.