国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

用java制作excel格式報表

2019-11-18 13:39:10
字體:
來源:轉載
供稿:網友

try{         getDBConnection();         pstmt = conn.PRepareStatement(strSql);         ret = pstmt.executeQuery();         File tempFile=new File(filename);         try{         WritableWorkbook workbook = Workbook.createWorkbook(tempFile);         WritableSheet sheet = workbook.createSheet("sheet1", 0);         Label l=null;         jxl.write.Number n=null;         jxl.write.DateTime d=null;         WritableFont headerFont = new WritableFont(WritableFont.ARIAL,12,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLUE);         WritableCellFormat headerFormat = new WritableCellFormat (headerFont);

         WritableFont titleFont = new WritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false, UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.RED);         WritableCellFormat titleFormat = new WritableCellFormat (titleFont);

         WritableFont detFont = new WritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false, UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);         WritableCellFormat detFormat = new WritableCellFormat (detFont);

         NumberFormat nf=new NumberFormat("0.00000");         WritableCellFormat priceFormat = new WritableCellFormat (detFont, nf);

         DateFormat df=new DateFormat("yyyy-MM-dd");         WritableCellFormat dateFormat = new WritableCellFormat (detFont, df);

         l=new Label(2,0,"",headerFormat);         sheet.addCell(l);         int intTitle = title.length;         for (int i=0;i<intTitle;i++)         {           l=new Label(i,2,title[i], titleFormat);           sheet.addCell(l);         }        int k = 0;        while(ret.next())                {                  k++;                  for (int j=1;j<intTitle;j++)                        {              l=new Label(j-1,k+3,ret.getString(j),detFormat);              sheet.addCell(l);                          //sheet.setColumnView(j,30);                        }                }         workbook.write();         workbook.close();         } catch(Exception e){}    }   catch(SQLException ae) {        throw new applicationException("創建Excel時查詢數據庫操作失敗! " +             "錯誤信息:" +strSql + ",異常信息為 :/n" + ae.getMessage());     } finally {                closeResultSet(ret);                closeStatement(pstmt);                closeConnection();                   }}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 江津市| 离岛区| 滨海县| 黄山市| 宁城县| 萍乡市| 格尔木市| 崇明县| 娄烦县| 银川市| 兰坪| 莱芜市| 开江县| 伊春市| 博罗县| 宣化县| 定陶县| 湟源县| 基隆市| 清水县| 旬邑县| 合川市| 盘山县| 康保县| 尼玛县| 宜宾县| 多伦县| 天门市| 明溪县| 凉山| 全南县| 博湖县| 扶余县| 武城县| 监利县| 西丰县| 东源县| 塘沽区| 彭州市| 锦州市| 尤溪县|