jsp中poi实现导入导出excel

jsp中poi实现导入导出excel

ID:34723957

大小:130.18 KB

页数:13页

时间:2019-03-10

jsp中poi实现导入导出excel_第1页
jsp中poi实现导入导出excel_第2页
jsp中poi实现导入导出excel_第3页
jsp中poi实现导入导出excel_第4页
jsp中poi实现导入导出excel_第5页
资源描述:

《jsp中poi实现导入导出excel》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、1.excel导入数据导入时候注意数字类型和字符类型的区别,数字类型要在excel中设置数字类型,对应数据库中也应该建立对应类型<%@pageimport="com.guanri.database.*,java.util.*,com.guanri.util.*,com.jspsmart.upload.*"contentType="text/html;charset=GBK"%><%@pageimport="java.util.*,java.io.*,org.apache.poi.poifs.fil

2、esystem.*,org.apache.poi.hssf.usermodel.*"%><% Stringresult="";StringcontracId="";Stringprojectname="";doubleprojectscale=0;Stringprojecttype="";Stringprojectconunit="";doubledesigntime=0;Stringdesignphase="";

3、doublecompletedtime=0;Stringparticipants="";Stringpositionofpro="";Stringdutiesas="";intinum=0;intunum=0;intrnum=0;intsnum=0;Stringrmstr="";Tabletb=newTable();Vectorvc=null;Hashtablerows=newHashtable();Stringsql="";if(request.getMethod().equalsIgnoreC

4、ase("POST")){ Stringsdir="/download/xlsdir/";  //文件保存目录 String filesep=System.getProperty("file.separator"); Stringssdir=filesep+"download"+filesep+"xlsdir"+filesep; Calendarc=Calendar.getInstance();   Stringfname=c.getTimeInMillis()+".xls"; Stringsfn

5、ame=sdir+fname; Stringss="xls"; //支持的文件后缀名 try{  SmartUploadsu=newSmartUpload();  su.initialize(pageContext);  su.setAllowedFilesList(ss);  su.upload();  com.jspsmart.upload.Filefile=su.getFiles().getFile(0);  if(!file.isMissing()){     file.saveAs(sf

6、name); //  System.out.println(application.getRealPath("/")+ssdir+fname);   FileInputStreamfinput=newFileInputStream(application.getRealPath("/")+ssdir+fname);   //设定FileINputStream读取Excel档    POIFSFileSystemfs=newPOIFSFileSystem(finput);   HSSFWorkboo

7、kwb=newHSSFWorkbook(fs);   HSSFSheetsheet=wb.getSheetAt(0);   //读取第一个工作表,宣告其为sheet    finput.close();   HSSFRowrow=null;   //宣告一列    HSSFCellcell=null;   //宣告一个储存格    shorti=0;   shorty=0;    //以巢状迴圈读取所有储存格资料    System.out.println("sheet.getLastRowNum

8、()="+sheet.getLastRowNum());   for(i=1;i<=sheet.getLastRowNum();i++)   {     row=sheet.getRow(i);     for(y=1;y<=row.getLastCellNum();y++)     {        cell=row.getCell(y);        switch(y){          case1:   //合同号           if(cell!=null){   

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。