91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Java中怎么操作Jxl實現導出數據生成Excel表格數據文件

發布時間:2022-03-02 11:02:59 來源:億速云 閱讀:173 作者:iii 欄目:web開發

這篇文章主要講解了“Java中怎么操作Jxl實現導出數據生成Excel表格數據文件”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Java中怎么操作Jxl實現導出數據生成Excel表格數據文件”吧!

實現:前臺用的框架是Easyui+Bootstrap結合使用,需要引入相應的Js、Css文件。頁面:Jsp、攔截請求:Servlet、邏輯處理:ClassBean、數據庫:SQLserver。

注意:Bean中操作SQL語句進行處理是公司內部方法,可替換為其它方法自行擴展!主要看代碼邏輯業務處理!

使用SQLserver數據庫進行多表連接查詢得出需要展出的數據

則前臺數據展示使用的是Easyui中的datagrid數據列表進行展示。

 隨機點擊一行數據,點擊詳情個人信息彈窗打開,數據以及被填充到彈窗中!

  拉到底部可見導出按鈕,點擊導出發送請求:傳入個人就診編號及卡號進行SQL查詢個人數據實現導出

 此時此刻Java操作Jxl生成Excel文件成功直接,讓我們打開文件查看數據是否和我們后臺設置的預期效果一致!

表格數據和預期效果一致代碼如下:

Bean代碼:

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import jxl.CellView;
import jxl.Workbook;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;


public class ImportBean {
    
    private HttpServletRequest request;//客戶端請求對象
    private DBSource db; //操作SQL語句對象
    private String MSG;  //提示信息
    
    
    //構造函數
    public ImportBean(HttpServletRequest request) {
        this.request = request;
        this.db = new DBSource(request); // 數據庫對象
    }
    
    
    

    //主訴與癥狀下拉框
    public Vector loadZSZZCombo() throws SQLException{
        Vector vec = null;
        String sql ="  select '' as comboValue,'請選擇' as comboName, '' as combotext  "+ 
                "union all " +
                "select [編號],[主訴與癥狀],[查體]  FROM [V_醫務管理_主訴癥狀信息表]";
        sql+=" ORDER BY comboValue ";
        vec = db.getConttexJONSArr(sql, 0, 0);
        return vec;
    }
        
    
    
    //頁面初始化讀取就診信息
    public Vector queryJZXX(int pageNum, int pageSize,String JZBH,String KH) throws SQLException{
        String sql = ""; // 查詢用SQL語句
        Vector vec = null; // 結果集    
        
        sql="select 就診編號,卡號,姓名,班級或部門,人員類型,就診醫生,convert(nvarchar(19),就診時間,21) as 就診時間,主訴與癥狀,查體,是否隔離,診斷結果,診療意見,病歷類型,isnull(轉院原因,'') as 轉院原因,isnull(轉診醫院,'') as 轉診醫院,isnull(轉診醫生,'') as 轉診醫生,isnull(convert(nvarchar(19),轉院時間,21),'') as 轉院時間  from ( SELECT l.就診編號,a.[卡號],a.[姓名],b.班級名稱 as 班級或部門,'1' as 人員類型,j.就診醫生,j.就診時間  as 就診時間,l.主訴與癥狀,l.查體,l.是否隔離,l.診斷結果,l.診療意見,l.病歷類型,z.轉院原因,z.轉診醫院,z.轉診醫生,z.轉院時間" + 
            " from [V_基礎信息_學生信息表] a "+
            " left join [V_醫務管理_就診信息] j on j.卡號=a.卡號  left join [V_醫務管理_病歷信息] l on l.就診編號=j.編號  " + 
            " left join [V_醫務管理_轉院信息] z on z.就診編號=j.編號  left join dbo.V_基礎信息_班級信息表 b on a.[行政班代碼]=b.班級代碼  "+
            " union all SELECT l.就診編號,a.[卡號],a.[姓名],c.CNAME as 班級或部門,'2' as 人員類型,j.就診醫生,convert(nvarchar(19),j.就診時間,21) as 就診時間,l.主訴與癥狀,l.查體,l.是否隔離,l.診斷結果,l.診療意見,l.病歷類型,isnull(z.轉院原因,'') as 轉院原因,isnull(z.轉診醫院,'') as 轉診醫院,isnull(z.轉診醫生,'') as 轉診醫生,isnull(convert(nvarchar(19),z.轉院時間,21),'')as 轉院時間  " + 
            " from [V_基礎信息_教職工信息表] a  "+
            " left join [V_醫務管理_就診信息] j on j.卡號=a.卡號  left join [V_醫務管理_病歷信息] l on l.就診編號=j.編號  "+
            " left join [V_醫務管理_轉院信息] z on z.就診編號=j.編號  left join [sysUserDept] b on a.卡號=b.[UserCode] "+
            " left join [sysDepartment] c on b.[DeptCode]=c.[DeptCode] ) x  WHERE 1=1 AND x.就診醫生!='null' ";
        
        
        if(!"".equalsIgnoreCase(JZBH)){
            sql+=" AND x.就診編號='"+ MyTools.fixSql(JZBH) +"' ";
        }
        if(!"".equalsIgnoreCase(KH)){
            sql+=" AND x.卡號='"+ MyTools.fixSql(KH) +"' ";
        }
        
        sql+=" ORDER BY x.人員類型,x.[卡號]  desc";
        vec = db.getConttexJONSArr(sql, pageNum, pageSize);
        return vec;
    }
    
    
    
    //導出excel表格
    public String outputGRXX(String JZBH,String KH)throws SQLException {
        Vector vec = null;
        Vector vec2 = null;
        String sql="";
        String sql2="";
        String savePath="";
        
        sql="select 卡號,姓名,班級或部門,人員類型,就診醫生,convert(nvarchar(19),就診時間,21) as 就診時間,主訴與癥狀,查體,是否隔離,診斷結果,診療意見,病歷類型,是否轉院,isnull(轉院原因,'') as 轉院原因,isnull(轉診醫院,'') as 轉診醫院,isnull(轉診醫生,'') as 轉診醫生,isnull(convert(nvarchar(19),轉院時間,21),'') as 轉院時間  from ( SELECT l.就診編號,a.[卡號],a.[姓名],b.班級名稱 as 班級或部門,'1' as 人員類型,j.就診醫生,j.就診時間  as 就診時間,l.主訴與癥狀,l.查體,l.是否隔離,l.診斷結果,l.診療意見,l.病歷類型,是否轉院='',z.轉院原因,z.轉診醫院,z.轉診醫生,z.轉院時間" + 
                " from [V_基礎信息_學生信息表] a "+
                " left join [V_醫務管理_就診信息] j on j.卡號=a.卡號  left join [V_醫務管理_病歷信息] l on l.就診編號=j.編號  " + 
                " left join [V_醫務管理_轉院信息] z on z.就診編號=j.編號  left join dbo.V_基礎信息_班級信息表 b on a.[行政班代碼]=b.班級代碼  "+
                " union all SELECT l.就診編號,a.[卡號],a.[姓名],c.CNAME as 班級或部門,'2' as 人員類型,j.就診醫生,convert(nvarchar(19),j.就診時間,21) as 就診時間,l.主訴與癥狀,l.查體,l.是否隔離,l.診斷結果,l.診療意見,l.病歷類型,是否轉院='',isnull(z.轉院原因,'') as 轉院原因,isnull(z.轉診醫院,'') as 轉診醫院,isnull(z.轉診醫生,'') as 轉診醫生,isnull(convert(nvarchar(19),z.轉院時間,21),'')as 轉院時間  " + 
                " from [V_基礎信息_教職工信息表] a  "+
                " left join [V_醫務管理_就診信息] j on j.卡號=a.卡號  left join [V_醫務管理_病歷信息] l on l.就診編號=j.編號  "+
                " left join [V_醫務管理_轉院信息] z on z.就診編號=j.編號  left join [sysUserDept] b on a.卡號=b.[UserCode] "+
                " left join [sysDepartment] c on b.[DeptCode]=c.[DeptCode] ) x  WHERE 1=1 AND x.就診醫生!='null'  AND x.就診編號='"+ MyTools.fixSql(JZBH) +"' AND x.卡號='"+ MyTools.fixSql(KH) +"' ";
        
        vec=db.GetContextVector(sql);
        
        //查詢主訴與癥狀下拉框
        sql2="select [編號],[主訴與癥狀],[查體]  FROM [V_醫務管理_主訴癥狀信息表]";
        vec2=db.GetContextVector(sql2);
        
        //生成excel表
        if (vec != null && vec.size() > 0) {
            Calendar c = Calendar.getInstance();// 可以對每個時間域單獨修改
            savePath = MyTools.getProp(request, "Base.exportExcelPath");//導出excel文件服務器保存路徑:F\:/UPLOAD/XZLMS/exportExcel/    
            
            //創建文件夾
            File file = new File(savePath);
            if (!file.exists()) {
                file.mkdirs();
            }
            savePath +=vec.get(1).toString() +"就診記錄詳情"+ ".xls";
            System.out.println(savePath);
            try {
                OutputStream os = new FileOutputStream(savePath);
                WritableWorkbook wbook = Workbook.createWorkbook(os);// 建立excel文件
                WritableSheet wsheet1 = wbook.createSheet(vec.get(1).toString(), 0);// 對第一張sheete,生成的工作表名稱
                WritableFont fontStyle;
                WritableCellFormat contentStyle;
                Label content;
                
                //生成標題
                String[] title1=new String[]{"卡號","姓名","班級或部門","人員類型","就診醫生","就診時間","主訴與癥狀","查體","是否隔離","診斷結果","診療意見","病歷類型","是否轉院","轉院原因","轉診醫院","轉診醫生","轉院時間"};
                int counum1=0;//excel表中行數
                String cellContent1 = ""; //當前單元格的內容
                
                for(int i=0;i<title1.length;i++) {
                    wsheet1.setColumnView(i, 25);//設置每列列寬
                }
                
                
                //第1行生成標題設置行列字體大小
                fontStyle = new WritableFont(WritableFont.createFont("宋體"), 20, WritableFont.BOLD,false, jxl.format.UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);
                contentStyle = new WritableCellFormat(fontStyle);
                contentStyle.setShrinkToFit(true);
                contentStyle.setWrap(true);
                contentStyle.setAlignment(jxl.format.Alignment.CENTRE);//水平居中
                contentStyle.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);//垂直居中
                    
                wsheet1.mergeCells(0, counum1, 16, counum1); //合并單元格mergeCells(a,b,c,d) a 單元格的列號,b 單元格的行號,c 從單元格[a,b]起,向左合并到c列,d 從單元格[a,b]起,向下合并到d行
                cellContent1 = "個人就診信息詳情表";
                content = new Label(0, counum1, cellContent1, contentStyle); //單元格內容
                wsheet1.addCell(content);
                wsheet1.setRowView(counum1, 600);  //設置行高
                
                
                //第2行生成對應數據標題名稱。
                counum1++;
                for(int colNum=0; colNum<17; colNum++){
                    fontStyle = new WritableFont(WritableFont.createFont("宋體"), 12, WritableFont.NO_BOLD,false, jxl.format.UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);
                    contentStyle = new WritableCellFormat(fontStyle);
                    contentStyle.setShrinkToFit(true);
                    contentStyle.setAlignment(jxl.format.Alignment.CENTRE);//水平居中
                    contentStyle.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);//垂直居中
                    //設置邊框; 
                    contentStyle.setBorder(jxl.format.Border.TOP, BorderLineStyle.THIN);
                    contentStyle.setBorder(jxl.format.Border.LEFT, BorderLineStyle.THIN);
                    contentStyle.setBorder(jxl.format.Border.RIGHT, BorderLineStyle.THIN);
                    contentStyle.setBorder(jxl.format.Border.BOTTOM, BorderLineStyle.THIN);
                    //創建單元格 ,一行一個格子的增加                            
                    cellContent1=title1[colNum];                        
                    content = new Label(colNum, counum1, cellContent1, contentStyle);
                     //添加到行中;  
                    wsheet1.addCell(content);    
                }
                wsheet1.setRowView(counum1, 1000);  //設置行高
                
                
                
                //第3行生成內容數據
                counum1++;
                for(int i=0;i<vec.size();i=i+18){//控制行數
                    
                    for(int colNum=0; colNum<17; colNum++){//控制列數
                        fontStyle = new WritableFont(WritableFont.createFont("宋體"), 12, WritableFont.NO_BOLD,false, jxl.format.UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);
                        contentStyle = new WritableCellFormat(fontStyle);
                        contentStyle.setWrap(true);
                        contentStyle.setShrinkToFit(true);
                        contentStyle.setAlignment(jxl.format.Alignment.CENTRE);//水平居中
                        contentStyle.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);//垂直居中
                        //邊框
                        contentStyle.setBorder(jxl.format.Border.TOP, BorderLineStyle.THIN);
                        contentStyle.setBorder(jxl.format.Border.LEFT, BorderLineStyle.THIN);
                        contentStyle.setBorder(jxl.format.Border.RIGHT, BorderLineStyle.THIN);
                        contentStyle.setBorder(jxl.format.Border.BOTTOM, BorderLineStyle.THIN);
                        
                        //對某一列進行判斷進行單獨處理
                        if(colNum==3) {
                            if(vec.get(i+colNum).toString().equalsIgnoreCase("1")) {
                                cellContent1="學生";
                            }else {
                                cellContent1="教師";
                            }
                            content = new Label(colNum, counum1, cellContent1, contentStyle);//創建單元格 第?列單元格Y坐標 ,第?行X坐標,內容,樣式
                            wsheet1.addCell(content); //添加到行中;  
                        }else if(colNum==6) {//癥狀
                            for(int j=0;j<vec2.size();j=j+3) {
                                if(vec2.get(j+0).toString().equalsIgnoreCase(vec.get(i+colNum).toString())) {
                                    cellContent1=vec2.get(j+1).toString();
                                }
                            }
                            content = new Label(colNum, counum1, cellContent1, contentStyle);//創建單元格 第?列單元格Y坐標 ,第?行X坐標,內容,樣式
                            wsheet1.addCell(content); //添加到行中;  
                        }else if(colNum==8) {//隔離
                            if(vec.get(i+colNum).toString().equalsIgnoreCase("0")) {
                                cellContent1="否";
                            }else {
                                cellContent1="是";
                            }
                            content = new Label(colNum, counum1, cellContent1, contentStyle);//創建單元格 第?列單元格Y坐標 ,第?行X坐標,內容,樣式
                            wsheet1.addCell(content); //添加到行中;  
                        }else if(colNum==11) {//病歷類型
                            if(vec.get(i+colNum).toString().equalsIgnoreCase("1")) {
                                cellContent1="初診";
                            }else {
                                cellContent1="復診";
                            }
                            content = new Label(colNum, counum1, cellContent1, contentStyle);//創建單元格 第?列單元格Y坐標 ,第?行X坐標,內容,樣式
                            wsheet1.addCell(content); //添加到行中;  
                        }else if(colNum==12) {//是否轉院
                            if(vec.get(i+(colNum+1)).toString().equalsIgnoreCase("")) {
                                cellContent1="否";
                            }else {
                                cellContent1="是";
                            }
                            content = new Label(colNum, counum1, cellContent1, contentStyle);//創建單元格 第?列單元格Y坐標 ,第?行X坐標,內容,樣式
                            wsheet1.addCell(content); //添加到行中;  
                        }else{
                             //正常拼接值
                            cellContent1=vec.get(i+colNum).toString();
                            content = new Label(colNum, counum1, cellContent1, contentStyle);//創建單元格 第?列單元格Y坐標 ,第?行X坐標,內容,樣式
                            wsheet1.addCell(content); //添加到行中;  
                        }
                        
                    }
                        
                    wsheet1.setRowView(counum1, 1500);  //設置行高
                    counum1++;
                }
                
                // 寫入數據
                wbook.write();
                // 關閉文件
                wbook.close();
                os.close();
                this.setMSG("文件生成成功");
            } catch (FileNotFoundException e) {
                this.setMSG("導出前請先關閉相關EXCEL");
            } catch (WriteException e) {
                this.setMSG("文件生成失敗");
            } catch (IOException e) {
                this.setMSG("文件生成失敗");
            }
        } else {
            this.setMSG("沒有符合條件的成績信息");
        }
        return savePath;
    }
        
    
    //Get&Set
    public String getMSG() {
        return MSG;
    }

    public void setMSG(String mSG) {
        MSG = mSG;
    }    

}

Servlet代碼:

public class ImportBean_Servlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        //設置字符編碼為UTF-8
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        
        String active = MyTools.StrFiltr(request.getParameter("active"));// 拿取前臺的active值
        int pageNum = MyTools.parseInt(request.getParameter("page"));    //獲得頁面page參數 分頁
        int pageSize = MyTools.parseInt(request.getParameter("rows"));    //獲得頁面rows參數 分頁
        
        TraceLog.Trace("active...:"+active);
        Vector jsonV = null;//返回結果集
        JSONArray jal = null;//返回json對象     
        ImportBean bean = new ImportBean(request); //對象
        
        //查詢主訴與癥狀
        if("loadZSZZCombo".equalsIgnoreCase(active)){
            try {
                jsonV = bean.loadZSZZCombo();
                jal = (JSONArray) jsonV.get(2);
                response.getWriter().write(jal.toString());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        //查詢就診信息
        if("queryJZXX".equalsIgnoreCase(active)){
            try {
                String JZBH=URLDecoder.decode(MyTools.StrFiltr(request.getParameter("JZBH")), "UTF-8");//就診編號
                String KH=URLDecoder.decode(MyTools.StrFiltr(request.getParameter("KH")), "UTF-8");//卡號
                jsonV = bean.queryJZXX(pageNum,pageSize,JZBH,KH);
                if (jsonV != null && jsonV.size() > 0) {
                    //最終處理:傳回AJAX 結果集
                    jal = (JSONArray)jsonV.get(2);
                    response.getWriter().write("{\"total\":" + MyTools.StrFiltr(jsonV.get(0)) + ",\"rows\":" + jal.toString() + "}");//生成datagrid所需數據類型
                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                jal = JsonUtil.addJsonParams(jal, "MSG", "查詢錯誤!"+ bean.getMSG() );
                response.getWriter().write(jal.toString());
            }
        }
        
        //導出個人信息詳情Exls表格
        if("outputGRXX".equalsIgnoreCase(active)){
            String JZBH=URLDecoder.decode(MyTools.StrFiltr(request.getParameter("JZBH")), "UTF-8");//就診編號
            String KH=URLDecoder.decode(MyTools.StrFiltr(request.getParameter("KH")), "UTF-8");//卡號
            try {
                String filePath=bean.outputGRXX(JZBH,KH); //調用bean方法入參,返回生成文件路徑
                jal = JsonUtil.addJsonParams(jal, "MSG",bean.getMSG()); //生成json格式數據,返回狀態值
                jal = JsonUtil.addJsonParams(jal, "filePath", filePath);//生成json格式數據,返回路徑
                response.getWriter().write(jal.toString());
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
                
                
        
        
        
    }
}

Jsp:代碼:

<body>
    <%-- 遮罩層 --%>
       <div id="divPageMask" class="maskStyle">
           <div id="maskFont">文件生成中,請稍后...</div>
       </div>

    <div class="bg-box indexBox" >
        <div class="box">
            <div class="col-lg-10 col-md-10 col-sm-12 col-xs-12 content" style="width:100%;">
                <div class="content-border">
                    <ol class="breadcrumb">
                        <li>就診信息</li>
                        <li class="active"><b>查詢條件</b></li>
                    </ol>
                    
                    <!-- 列表區 -->
                    <div id="tableDIV" class="list-table table-responsive" style="height:400px;">
                        <table id="JZXXList" width="100%"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    
    
    <!-- 個人詳細詳情dialog -->
    <div id="grxxInfoDialog" style="overflow:auto;">
        <div class="col-lg-10 col-md-10 col-sm-12 col-xs-12 content" style="width:100%;">
            <div class="content-border">
                <div id="querybox">    
                <form id="form3" name="form3" method="post" class="colorForm">        
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">姓名</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-4 col-xs-4" style="height:34px;">
                            <span  id="BRXM_DC" style="font-size:16px;"></span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">班級或部門</label>
                        </div>
                        <div class="col-lg-8 col-md-8 col-sm-4 col-xs-4" style="height:34px;">
                            <span id="BJBM_DC" style="font-size:16px;"></span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">人員類型</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                              <input class="form-control" id="SRYLX_DC" name="SRYLX" style="width:100%;" />  
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">就診醫生</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                              <input class="form-control" id="JZYS_DC" name="JZYS" style="width:100%;" />  
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">就診時間</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:34px;">
                            <input class="form-control" id="JZSJ_DC" name="JZSJ" style="width:100%;" />  
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">主訴與癥狀</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                            <input class="form-control" id="ZSYZZ_DC" name="ZSYZZ" style="width:100%;" />  
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">查體</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:80px;">
                            <textarea class="form-control" id="CT_DC" name="CT" style="width:100%; height:80px;"></textarea>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">是否隔離</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                              <input class="form-control" id="SFGL_DC" name="SFGL" style="width:100%;" />  
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">類型</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                              <input class="form-control" id="BLLX_DC" name="BLLX" style="width:100%;" />  
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">診斷結果</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:80px;">
                            <textarea class="form-control" id="ZDJG_DC" name="ZDJG" style="width:100%; height:80px;"></textarea>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">診療意見</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:80px;">
                            <textarea class="form-control" id="ZLYJ_DC" name="ZLYJ" style="width:100%; height:80px;"></textarea>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">是否轉院</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                              <input class="form-control" id="SFZY_DC" name="SFZY" style="width:100%;" />  
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">轉院原因</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:80px;">
                            <textarea class="form-control" id="ZYYY_DC" name="ZYYY" style="width:100%; height:80px;"></textarea>
                        </div>
                    </div>
                     
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">轉診醫院</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                            <input class="form-control" id="ZZYY_DC" name="ZZYY" style="width:100%;" maxlength="20"/>
                        </div>
                    </div>
                     
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">轉診醫生</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                            <input class="form-control" id="ZZYS_DC" name="ZZYS" style="width:100%;" maxlength="20"/>
                        </div>
                    </div>
                     
                    <div class="row">
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2" style="height:34px;">
                            <label class="formRowTitle">轉院時間</label>
                        </div>
                        <div class="col-lg-10 col-md-10 col-sm-10 col-xs-10" style="height:40px;">
                            <input class="form-control" id="ZYSJ_DC" name="ZYSJ" style="width:100%;" />  
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center">
                            <input type="button" id="outputGRXX" class="btn form-control btn-success dialogButtom-btn" value="導出" onclick="doToolbar(this.id);"/>
                        </div>
                    </div>
                        <input type="hidden" id="active2" name="active"/>
                        <input type="hidden" id="JZBH_DC" name="JZBH"/><!-- 人員姓名 -->
                        <input type="hidden" id="KH_DC" name="KH"/><!-- 班級或部門 -->
                    </form>
                </div>
            </div>
        </div>
    </div>
    
    <iframe id="exportIframe" src="" style="width:0; height:0;"></iframe>
</body>
  <script type="text/javascript">
      var userCode = '<%=usercode%>';
      var sAuth = '<%=sAuth%>';
      var curPageNumber = 1;
      var curPageSize = 20;
      var lodata='';
      var jzbh='';//就診編號
      var kh='';//卡號
      
      
      
      $(document).ready(function(){
          $('#hideQueryArea').collapse('hide');
          var tableheight=($(window).height()-308); //瀏覽器當前窗口可視區域高度
        $('#tableDIV').css("height", tableheight);
          if(screen.height>900){
              dialogheight=160;
          }else{
              dialogheight=10;
          }
          initDialog();//初始化對話框
          loadfiand();//初始化主訴癥狀
          loadGridJZXX();//頁面初始化datagrid
          
    });
    
      
      
      //加載主訴癥狀
    function loadfiand(){
        $.ajax({
            type:"post",
            url:'<%=request.getContextPath()%>/ImportBean_Servlet?active=loadZSZZCombo',
            dataType:"json",
            success: function(data){
                lodata='';
                lodata=data;
            }
        });
    }
    
      
      /**加載 dialog控件**/
    function initDialog(){        
        //個人詳細信息彈窗
        $('#grxxInfoDialog').dialog({  
            width: 580,//寬度設置   
            height: 480,//高度設置 
            top: dialogheight,
            modal:true,
            closed: true,   
            cache: false, 
            draggable:false,//是否可移動dialog框設置
            //打開事件
            onOpen:function(data){},
            //讀取事件
            onLoad:function(data){},
            //關閉事件
            onClose:function(data){}
        });

    }
      
      
      //頁面初始化datagrid:查詢就診信息
    function loadGridJZXX(){
        $('#JZXXList').datagrid({
            url: '<%=request.getContextPath()%>/ImportBean_Servlet',
             queryParams:{"active":"queryJZXX"}, 
            nowrap: false,//當數據長度超出列寬時將會自動截取
            fit:true,//自動折疊容器的大小將填充父容器
            showFooter:true,//顯示視圖的頁腳
            striped:true, //隔行變色
            pagination:true,//開啟分頁
            pageSize:curPageSize,//每頁查看的記錄數量
            singleSelect:true,//開啟單選模式
            pageNumber:curPageNumber,//初始的頁面為第一頁
            rownumbers:true,//顯示行數
            fitColumns: true,//自適應
             fit:true,
                width:'100%',
                nowrap:false,
                striped:true,
                pageSize:20,
                pageNumber:1,
                showFooter:true,
                rownumbers:true,
                singleSelect:true,
                pagination:true,
                fitColumns:false,
                //不使用后臺排序
                remoteSort :false,
                async:false,
            
            //下面是表單中加載顯示的信息
            columns:[[
                {field:'姓名',align:'center',title:'姓名',width:fillsize(0.1)},
                {field:'班級或部門',align:'center',title:'班級/部門',width:fillsize(0.16)},
                {field:'主訴與癥狀',align:'center',title:'主訴與癥狀',width:fillsize(0.15),
                        formatter:function(value){
                            for(var i=0; i<lodata.length; i++){
                                if (lodata[i].comboValue == value) {
                                    return lodata[i].comboName;
                                }
                            }
                            return value;
                    }},
                    {field:'病歷類型',align:'center',title:'類型',width:fillsize(0.1),
                        formatter:function(value,rec){
                            var bllx="";
                            if(rec.病歷類型=='1'){
                                bllx="初診";
                            }else{
                                bllx="復診";
                            }
                            return bllx;
                        }
                    },
                {field:'就診醫生',align:'center',title:'就診醫生',width:fillsize(0.1)},
                {field:'就診時間',align:'center',title:'就診時間',width:fillsize(0.2)},
                {field:'info',align:'center',title:'操作',width:fillsize(0.1),
                    formatter:function(value,rec){
                        var info='<input type="button" class="btn btn-primary" id="queBL" style="width:60px;" value="詳情" onclick="openPersonBLSY(\''+rec.就診編號+'\',\''+rec.卡號+'\')"">';
                        return info;
                    }    
                }
            ]],
            //雙擊某行時觸發
            onDblClickRow:function(rowIndex,rowData){
            },
            //讀取datagrid之前加載
            onBeforeLoad:function(){},
            //單擊某行時觸發
            onClickRow:function(rowIndex,rowData){
                rowxx = rowData;
            },
            //加載成功后觸發
            onLoadSuccess: function(data){
                iKeyCode = '';
                row = '';
                curPageNumber = $(this).datagrid('options').pageNumber;
                curPageSize = $(this).datagrid('options').pageSize;
            },
            error:function(data){}
        });
    }
      
    
    
    //工具欄按鈕調用方法,傳入按鈕的id@id 當前按鈕點擊事件
    function doToolbar(iToolbar){
        //導出個人信息EXCl表格
        if(iToolbar == 'outputGRXX'){
            $('#active2').val('outputGRXX');//傳隱藏值active
            $("#form3").submit();//表單提交方法
        }
        
    }
    
    
    //提交的表單
    $('#form3').form({
        //定位到servlet位置的url
        url:'<%=request.getContextPath()%>/ImportBean_Servlet',
        //當點擊事件后觸發的事件
        onSubmit: function(data){
            return $(this).form('validate');//驗證
        }, 
        //當點擊事件并成功提交后觸發的事件
        success:function(data){
            var json = eval("("+data+")");
            if(json[0].MSG == '文件生成成功'){
                    //下載文件到本地
                $("#exportIframe").attr("src", '<%=request.getContextPath()%>/download.jsp?filePath=' + encodeURIComponent(json[0].filePath));
                $('#grxxInfoDialog').dialog("close");
                }else{
                    alertMsg(json[0].MSG);
                }
            
        }
    });

    
    
    
    //進行數據填充到個人信息彈窗,JZBH:就診編號,KH:卡號
    function openPersonBLSY(JZBH,KH){        
        $('#grxxInfoDialog').dialog({
            title:"個人詳細信息",
        });
        $.ajax({
            type : "POST",
            url : '<%=request.getContextPath()%>/ImportBean_Servlet',
            data : 'active=queryJZXX&JZBH='+JZBH+"&KH="+KH,
            dataType:"json",
            success : function(data){
                    $("#JZBH_DC").val(data.rows[0].就診編號);
                    $("#KH_DC").val(data.rows[0].卡號);
                     $("#BRXM_DC").html(data.rows[0].姓名);
                    $("#BJBM_DC").html(data.rows[0].班級或部門);
                    $("#JZYS_DC").val(data.rows[0].就診醫生);
                    $("#JZSJ_DC").val(data.rows[0].就診時間);
                    $("#CT_DC").val(data.rows[0].查體);
                    $("#ZDJG_DC").val(data.rows[0].診斷結果);
                    $("#ZLYJ_DC").val(data.rows[0].診療意見);
                    $("#ZYYY_DC").val(data.rows[0].轉院原因);
                    $("#ZZYY_DC").val(data.rows[0].轉診醫院);
                    $("#ZZYS_DC").val(data.rows[0].轉診醫生);
                    $("#ZYSJ_DC").val(data.rows[0].轉院時間);
                    
                     if (data.rows[0].是否隔離=='0') {
                        $('#SFGL_DC').val('否');
                     }else{
                        $('#SFGL_DC').val('是');
                     }
                     if(data.rows[0].人員類型=='1'){
                         $("#SRYLX_DC").val('學生');
                     }else{
                         $('#SRYLX_DC').val('老師');
                     }
                     if(data.rows[0].病歷類型=='1'){
                         $('#BLLX_DC').val('初診');
                     }else{
                         $('#BLLX_DC').val('復診');
                     }
                     if(data.rows[0].轉院原因!=''&&data.rows[0].轉診醫院!=''){
                        $("#SFZY_DC").val('是');
                     }else{
                        $("#SFZY_DC").val('否');
                     }
                     
                     for(var i=0; i<lodata.length; i++){
                        if (lodata[i].comboValue == data.rows[0].主訴與癥狀) {
                            $('#ZSYZZ_DC').val(lodata[i].comboName);
                        }
                    } 
                     
                     //表單禁用
                    $('#JZYS_DC').attr('readonly',true);
                    $('#CT_DC').attr('readonly',true);
                    $('#ZDJG_DC').attr('readonly',true);
                    $("#JZSJ_DC").attr('readonly',true);
                    $('#ZLYJ_DC').attr('readonly',true);
                    $('#ZYYY_DC').attr('readonly',true);
                    $('#ZZYY_DC').attr('readonly',true);
                    $('#ZZYS_DC').attr('readonly',true);
                    $("#ZYSJ_DC").attr('readonly',true);
                    $('#SFGL_DC').attr('readonly',true);
                    $('#ZSYZZ_DC').attr('readonly',true);
                    $('#SRYLX_DC').attr('readonly',true);
                    $('#BLLX_DC').attr('readonly',true);
                    $('#SFZY_DC').attr('readonly',true);
                
                $('#grxxInfoDialog').dialog('open');
            }
        });
    }
    
</script>

感謝各位的閱讀,以上就是“Java中怎么操作Jxl實現導出數據生成Excel表格數據文件”的內容了,經過本文的學習后,相信大家對Java中怎么操作Jxl實現導出數據生成Excel表格數據文件這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

肥东县| 五莲县| 玉林市| 景泰县| 兴城市| 平泉县| 湛江市| 哈密市| 乡宁县| 荆州市| 富蕴县| 丰镇市| 准格尔旗| 南靖县| 托克逊县| 滨海县| 武城县| 乡城县| 深圳市| 定西市| 神木县| 丰都县| 封丘县| 绥芬河市| 依兰县| 晋城| 堆龙德庆县| 济源市| 铁力市| 得荣县| 鄄城县| 错那县| 鹤壁市| 宾川县| 龙海市| 白沙| 河间市| 潍坊市| 闻喜县| 定西市| 赣州市|