<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    allen
    專注于java ee技術,包括struts,jsf,webwork,spring,hibernate,ibatis
    posts - 7,  comments - 9,  trackbacks - 0

    jxl在操作Excel文件時,要求文件需要保存在服務器端
    可以先用SmartUpload將文件上傳至服務器,再進行操作
    下面是個例子

    <%@ page language="java" contentType="text/html; charset=GBK" %>
    <%@page import="java.sql.*"%>
    <%@page import="java.io.*"%>
    <%@page import="java.util.*,jxl.*,ConnDatabase.SDatabase"%>
    <%@ page import="com.jspsmart.upload.*"%>
    <%@ include file="../public_js/yonghuhuodong.jsp" %>
    <script language="javascript" src="../public_js/public.js"></script>

    <LINK href="../class/<%=session.getAttribute("FactColorC") %>" rel=stylesheet>
    <script language=javascript src="../sale/js/mad.js"> </script>

    <jsp:useBean id="ViewBean" scope="page" class="ConnDatabase.SDatabase"/>

    ?

    <jsp:useBean? id="myUpload"? scope="page"? class="com.jspsmart.upload.SmartUpload" />

    ?

    <%

    String trace = "";
    String fileNames = request.getParameter("fname");
    //out.println(fileNames);
    //String fsections = request.getParameter("fsection");

    if(fileNames!=null && !fileNames.equals("")){
    ?try{
    ??//實例化上載bean
    ??com.jspsmart.upload.SmartUpload mySmartUpload=new com.jspsmart.upload.SmartUpload();
    ??//初始化
    ??mySmartUpload.initialize(pageContext);
    ??//設置上載的最大值
    ??mySmartUpload.setMaxFileSize(500 * 1024*1024);
    ??//上載文件
    ??mySmartUpload.upload();
    ??//循環取得所有上載的文件
    ??// 建立上傳目錄
    ??//java.io.File fileMkDir = new java.io.File(strSavePath);
    ??//fileMkDir.mkdirs();
    ??for (int i=0;i<mySmartUpload.getFiles().getCount();i++){
    ???//取得上載的文件
    ???com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i);
    ???if (!myFile.isMissing())
    ???{
    ????//取得上載的文件的文件名
    ????String myFileName=myFile.getFileName();
    ????//取得不帶后綴的文件名
    ????String? suffix=myFileName.substring(0,myFileName.lastIndexOf('.'));
    ????//取得后綴名
    ????String? ext= mySmartUpload.getFiles().getFile(0).getFileExt();?
    ????//取得文件的大小?
    ????int fileSize=myFile.getSize();
    ????//保存路徑
    ????String aa=getServletContext().getRealPath("/")+"jsp\\upload\\";
    ????trace=aa+myFileName;
    ????//System.out.println(trace);
    ????//取得別的參數
    ????String explain=(String)mySmartUpload.getRequest().getParameter("files");
    ????String send=(String)mySmartUpload.getRequest().getParameter("SaveEPrice");
    ????//將文件保存在服務器端
    ????myFile.saveAs(trace,mySmartUpload.SAVE_PHYSICAL);
    ???}
    ??}
    ?}catch(Exception e){
    ??System.out.println(e.getMessage());
    ??e.printStackTrace();
    ?}
    }
    //System.out.println("-----------------");
    ?java.io.File?? f=?? new?? java.io.File(trace);??
    ? f=f.getCanonicalFile();??
    ? InputStream?? is?? =?? new?? FileInputStream(f);??
    ? jxl.Workbook?? rwb?? =?? Workbook.getWorkbook(is);?
    ?? Sheet?? rs?? =?? rwb.getSheet(0);??
    ? int?? rsrows=rs.getRows();??
    ??? int allRec=rs.getRows();///得到該sheet的行數
    ???? int row = rs.getColumns(); //得到列數
    ?// out.print("行:"+allRec+"--列:"+row);
    ?? // Cell?? c1=rs.getCell(0,1);
    ? //? String s=c1.getContents();
    //?out.println(s);
    //List list=new ArrayList();
    String s1="";
    String s2="";
    String s3="";
    String s4="";
    String s5="";
    String s6="";
    String s7="";
    String s8="";
    String s9="";
    String custNo="";
    try{

    ?for(int?? i=2;i<allRec;i++){
    ??
    ?? for(int j=1;j<row;j++){
    ??????????
    ??????????
    ?????????? // c.setSection(fsections);? /
    ???//s1=fsections;
    ??????????? Cell?? c1=rs.getCell(1,i);
    ???Cell?? c2=rs.getCell(2,i);
    ????? Cell?? c3=rs.getCell(3,i);
    ???Cell?? c4=rs.getCell(4,i);
    ??????????? Cell?? c5=rs.getCell(5,i);
    ??????????? Cell?? c6=rs.getCell(6,i);
    ??????????? Cell?? c7=rs.getCell(7,i);
    ??????????? Cell?? c8=rs.getCell(8,i);
    ???//custNo=getMaxSequrence(fsections);
    ???s2=c1.getContents();
    ???s3=c2.getContents();
    ???s4=c3.getContents();
    ???s5=c4.getContents();
    ???s6=c5.getContents();
    ???s7=c6.getContents();
    ???s8=c7.getContents();
    ??????????? s9=c8.getContents();
    ???/*c.setCustName(c1.getContents());
    ???c.setCus_Sex(c2.getContents());
    ???c.setRoomNo(c3.getContents());
    ???c.setRoomNo(c4.getContents());???
    ???c.setAddress(c5.getContents());???
    ???c.setCardNo(c6.getContents());???????
    ???c.setPhone(c7.getContents());???????
    ???c.setRemark(c8.getContents());*/
    //???String fff=c1.getContents();?????????????
    ?? }
    ??
    ??????????????? }
    ?
    ??
    ?}
    ?out.println("<script language='javascript'>alert('成功添加');window.opener.location.reload();window.close();</script>");?
    }catch(Exception e){
    ?out.println("<script language='javascript'>alert('您提供的文件不正確!!!');window.close();</script>");
    }
    ?
    ?
    %>

    posted on 2006-10-11 18:29 robbin163 閱讀(579) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(3)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲精品视频免费| 国产在线国偷精品产拍免费| 免费少妇a级毛片人成网| 亚洲av无码有乱码在线观看| 在线免费视频一区| 亚洲heyzo专区无码综合| 午夜国产羞羞视频免费网站| 美女黄频a美女大全免费皮| 成人亚洲网站www在线观看| 九九全国免费视频| 亚洲中文字幕日产乱码高清app| 一级毛片免费播放试看60分钟| av在线亚洲欧洲日产一区二区| 岛国精品一区免费视频在线观看 | 亚洲av日韩精品久久久久久a| 丁香花在线观看免费观看| 亚洲欧美第一成人网站7777| 女人毛片a级大学毛片免费| 国产成人亚洲精品91专区高清| 亚洲午夜AV无码专区在线播放 | 77777亚洲午夜久久多人| 日本三级在线观看免费| 精品亚洲成AV人在线观看| 97无码免费人妻超级碰碰碰碰 | 国产麻豆成人传媒免费观看| 亚洲色图校园春色| 成人网站免费观看| 一区二区三区视频免费| 日本久久久久亚洲中字幕| 毛片免费全部免费观看| 成人久久久观看免费毛片| 亚洲大尺度无码无码专区| 中文字幕无码免费久久99| 免费观看又污又黄在线观看| 亚洲av日韩av无码黑人| 永久黄网站色视频免费| 全黄大全大色全免费大片| 99热亚洲色精品国产88| 久久伊人亚洲AV无码网站| 120秒男女动态视频免费| 国产亚洲漂亮白嫩美女在线|