string sheetname = "表名";1、合併單元格hssfworkbook hb = new hssfworkbook();
hssfsheet sheet = hb.createsheet(sheetname);
cellrangeaddress region = new cellrangeaddress(0, 0, 0, 3); // 開始行,結束行,開始列,結束列2、設定單元格格式sheet.addmergedregion(region); //將單元格新增到sheet中
hssfcellstyle contentstyle = hb.createcellstyle();3、設定單元格顏色contentstyle.setalignment(hssfcellstyle.align_center);// 水平居中
contentstyle.setverticalalignment(cellstyle.vertical_center);// 垂直居中
contentstyle.setwraptext(true); //自動換行
hssfcellstyle style = hb.createcellstyle();4、單元格中新增斜線style.setfillpattern(hssfcellstyle.solid_foreground);
style.setfillforegroundcolor(hssfcolor.red.index); //紅色
cell.setcellstyle(style);
hssfpatriarch patriarch = sheet.createdrawingpatriarch();hssfclientanchor a = new hssfclientanchor(0, 0, 1023, 255, (short) 0, 2, (short) 1, 2);
//起點在起點單元格中的具體位置,終點在終點單元格中的具體位置,起點的列,起點的行,終點的列,終點的行
hssf******shape shape1 = patriarch.create******shape(a);
shape1.setshapetype(hssf******shape.object_type_line);
shape1.setlinestyle(hssf******shape.linestyle_solid);
Excel 的處理一 POI 解析excel
03與07版本excel區別 一 字尾不同 前者.xls,後者.xslx 二 前者行數有最大行數限制 最大65536行 後者無行數限制 1.1 簡單方式 載入檔案路徑 獲取流 new fileinputstream filepath 再把流放入到工作簿裡,此時inputstream物件就讀取到工作簿...
POI操作Excel的封裝
日常辦公,我們使用的最多辦公軟體是microsoft的office,所以,我們開發的系統難免會遇到的乙個功能就是和office互動,所以,某些聰明的人,就開發了相應的功能包,使用我們程式設計師可以非常方便的進行microsoft office格式檔案的讀和寫,該功能包就是poi。對於poi具體某乙個...
POI資料的excel匯出
第一步 引入jar包 版本選擇 org.apache.poi poi3.17 org.apache.poi poi ooxml 3.17 第二步 工具類 第三步 controller層 通過以上的三步走,基本的匯出功能實現。但實際中可能不會這麼簡單,也會有很多負責的業務邏輯。例如 第 步 更改工具類...