日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

poi3.17使用

發布時間:2024/1/1 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 poi3.17使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
package lucene;import org.apache.poi.hssf.usermodel.*; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import java.io.FileOutputStream;/*** lucene全文檢索測試類* Created by Administrator on 2018/7/10.*/ public class LuceneTestController {//poi導出excelpublic void exportExcel() throws Exception{HSSFWorkbook wb = new HSSFWorkbook();HSSFSheet sheet = wb.createSheet("sheet name");//合并單元格sheet.addMergedRegion(new CellRangeAddress(0, 2, 0, 5));//設置第一列單元格寬度sheet.setColumnWidth(0,100*100);//設置第二列單元格寬度sheet.setColumnWidth(1,100*100);//創建第一行HSSFRow row0 = sheet.createRow(0);//創建第二行HSSFRow row1 = sheet.createRow(1);//設置第一行單元格高度row0.setHeight((short) 400);//創建第一行第一列單元格HSSFCell cell0_1 = row0.createCell(0);//創建第二行第一列單元格HSSFCell cell0_2 = row1.createCell(0);//設置單元格的值cell0_1.setCellValue("項目施工進度管理系統");//改變字體樣式,步驟HSSFFont hssfFont = wb.createFont();//設置字體,紅色hssfFont.setColor(HSSFFont.COLOR_RED);//字體粗體顯示hssfFont.setBold(true);hssfFont.setFontName("宋體");// 字體大小hssfFont.setFontHeightInPoints((short) 22);//設置樣式HSSFCellStyle cellStyle = wb.createCellStyle();cellStyle.setFont(hssfFont);//設置單元格背景色cellStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);//設置居中cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中//設置邊框cellStyle.setBorderBottom(BorderStyle.THIN); //下邊框cellStyle.setBorderLeft(BorderStyle.DASH_DOT_DOT);//左邊框cellStyle.setBorderTop(BorderStyle.THIN);//上邊框cellStyle.setBorderRight(BorderStyle.THIN);//右邊框//3.單元格使用樣式,設置第一行第一列單元格樣式cell0_1.setCellStyle(cellStyle);cell0_2.setCellStyle(cellStyle);//生成excel文件FileOutputStream fileOut = new FileOutputStream("e:\\"+System.currentTimeMillis()+".xls");wb.write(fileOut);fileOut.close();/* struts導出excel,前端需要是提交form形式,否則,點擊導出不會彈出框HSSFWorkbook wb = exportExcel(projectId, blockId, buildingId,buildingCode);// 生成excel文件String fileName = String.valueOf(Calendar.getInstance().getTimeInMillis()).concat(".xls");// 清空responsethis.getResponse().reset();this.getResponse().addHeader("Content-Disposition","attachment;filename=" + new String(fileName.getBytes()));this.getResponse().setContentType("application/vnd.ms-excel;charset=utf-8");OutputStream os = this.getResponse().getOutputStream();wb.write(os);if (os != null) {os.close();os = null;}wb.close();*/} }

轉自:https://blog.csdn.net/lhp_36kr/article/details/80139869

總結

以上是生活随笔為你收集整理的poi3.17使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。