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

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

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

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

    jxl在操作Excel文件時(shí),要求文件需要保存在服務(wù)器端
    可以先用SmartUpload將文件上傳至服務(wù)器,再進(jìn)行操作
    下面是個(gè)例子

    <%@ 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{
    ??//實(shí)例化上載bean
    ??com.jspsmart.upload.SmartUpload mySmartUpload=new com.jspsmart.upload.SmartUpload();
    ??//初始化
    ??mySmartUpload.initialize(pageContext);
    ??//設(shè)置上載的最大值
    ??mySmartUpload.setMaxFileSize(500 * 1024*1024);
    ??//上載文件
    ??mySmartUpload.upload();
    ??//循環(huán)取得所有上載的文件
    ??// 建立上傳目錄
    ??//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);
    ????//取得別的參數(shù)
    ????String explain=(String)mySmartUpload.getRequest().getParameter("files");
    ????String send=(String)mySmartUpload.getRequest().getParameter("SaveEPrice");
    ????//將文件保存在服務(wù)器端
    ????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的行數(shù)
    ???? int row = rs.getColumns(); //得到列數(shù)
    ?// 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) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

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

    常用鏈接

    留言簿(3)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    •  

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 亚洲国产午夜精品理论片在线播放| 精品一卡2卡三卡4卡免费视频| 亚洲中文字幕久久无码| 日本黄页网站免费| 免费观看一区二区三区| 亚洲日本视频在线观看| 亚洲精品动漫人成3d在线| 8x8x华人永久免费视频| 亚洲aⅴ无码专区在线观看| 久久夜色精品国产嚕嚕亚洲av| 免费看污成人午夜网站| 人妖系列免费网站观看| 九月婷婷亚洲综合在线| 久久青草精品38国产免费| 337p日本欧洲亚洲大胆裸体艺术| 猫咪免费人成网站在线观看| 美女被免费网站在线视频免费| 久久亚洲精品国产精品| 99爱免费观看视频在线| 国产成人亚洲精品蜜芽影院| 国产在线98福利播放视频免费| 久久免费精品视频| 香蕉视频免费在线播放| 亚洲丰满熟女一区二区v| 久久精品夜色噜噜亚洲A∨| 成年男女免费视频网站| 日本视频免费高清一本18| 黄页网站在线免费观看| 精品国产成人亚洲午夜福利| 久久青青草原亚洲AV无码麻豆| 伊人久久亚洲综合影院| 男人的好免费观看在线视频| 久久精品免费观看国产| 精品一区二区三区免费视频 | 亚洲第一街区偷拍街拍| 香蕉视频在线观看亚洲| 色噜噜亚洲精品中文字幕| 免费人成在线观看网站品爱网日本| 国产大片线上免费观看| 午夜网站在线观看免费完整高清观看| 四虎永久在线精品免费一区二区 |