Java三方---->excel框架之POI的使用一
Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能。pdf框架之IText的使用,参见我的博客:Java三方---->pdf框架之IText的使用。今天我们开始POI中Excel部分的学习。
POI框架的简单实例
我们通过案例来学习POI,项目结构如下:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVMAAAEjCAIAAAAAC3XiAAAgAElEQVR4nO2d63sURaKH+TvOh/PhPOdw9izu8SAu4LiyCGrU44K4jyuoq6yu46LsukdA7iCXhBBFRpIococQCAGCXDKEQAgBApoEwQsBmUBIAuYeIISkExL6fJhLV3VV9XRmOjNTqd/79OOT6a7qrhnn7arq6f4xRAcAqMeQaCq3tN3+Kmtf+qbc9E25G7bvu9txj9xa33b3tRX7omseAGBAiMp8z7qdDTevtjbWtDRev3zxQvpXWeTWG83t4z/KEtUFAMSRCM1vbGpduiL9UvGye1Wru6tWdV5c0XRq4Vcr585akDZrQdrSFemNTa2SmO91D3F7490IAGJMhOYvXZHe/kuRfuckZ+nr6rvfeevWHbH5Po9rSAhKO2qLy+Mzr3Z7zYWGROstzAcqEqH5sxdn6G1H+Yuu+6f3luYHrfZ5XCHDvW7Sdr/gISm97iFkHedkhflARYTmFxcXp6amirbOWLBRb9rPXx70jf8o60jF1ZSdp//y6QFebcJ8Q2mvm+2+iXUwHwAH4ZtfVFQ0bNiwoUOHiqq9P3OrfnOHf+mryz66b/vHy3M+mJH1wYysyks3D5y9MnbGtmfmZH97+Wbe/vNMbZ75hNkExlpr88nxAX26MM0cuGtgPlAOjvl+7SdPnmxh/p/dW/SaDXrNhq4rGxcuzUn/+uL+mj7/cqi2r1V74C9W2dj17od7mdq80T7ffENyk/nsNJ85g5gmD/Q+jD3DfKAiZvND2k+ZMsXC/Bdf36pf/bzz0pp/zt31Sd7V3Evd7LL+VMs7M711N+8wtUl1ia6Xb76tPj+4C8sdGv09eWyYD1SEMp/U3tr8pFeyO39Y+e6Hu5dl+7ZVdLBLek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GmG8b5PABmZDh6yaH+cjhAxLBnZwkGnKYjxw+IAdeacIC5TDfD3L4AHAKmcwHADgFzAdARWA+ACoC8wFQEZnMRw4fAE4hmfnI4QPAEWQyP3Y5fLpO3EU76O4FkOJGEzDAyGR+7HL4dD0hzA+bg2F1G73w+VmYD3S5zI9tDl/czeeGz1Hbxf7SDwcOriELcASZzI9tDl/czSfxMUly7Bp6ozBUBgBdl8v8iHP4yKfzg12g13YeHpGaZh5YGystgmwCx/KY9h9+LE/APLrLzZYTFLd6ej1RU+LAQCOT+VHk8LFJLGGD6CjzBRl+7HCcm7tGBMFxHuEOD5BnE2IAAAEeSURBVD99h5cKbWoNv7oMKXFgoJHD/Khz+PQoUrHESV404s5cGJVjJ9OOP0+3Doex3+cnakocGGjkMD/qHD59QMxnB8P83DVBVE6ognhULbw8x82W07mvGZNlSIkDA40c5uvR5vBFk4dnleFnzrfj567xzA+bacf98Y2bbkfNICxD5uRJiQMDjTTmR5PDF10enjjDT3B5jMld4/f5YTLtuOFz1NmA2QG5lY2OkyolDgw0cpgfdQ4fIIDaQBbzo87hAwa4hQ/ospgfdQ4f0HVdppQ4MNDIYb4f5PAB4BQymQ8AcAqYD4CKwHwAVATmA6AiMB8AFYH5AKgIzAdARWA+ACoC8wFQEZgPgIrAfABUBOYDoCIwHwAVgfkAqMj/AxQPyBNYIiu9AAAAAElFTkSuQmCC" alt="" />
一、 创建工作薄
@Test
public void createExcel() throws Exception {
// 建立xls文件,只需要引入poi-3.14-20160307.jar
Workbook wb1 = new HSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("excel/workbook.xls");
wb1.write(fileOut);
fileOut.close();
wb1.close(); // 需要额外引入poi-ooxml-3.14-20160307.jar, xmlbeans-2.6.0.jar, poi-ooxml-schemas-3.14-20160307.jar
Workbook wb2 = new XSSFWorkbook();
FileOutputStream fileOut2 = new FileOutputStream("excel/workbook.xlsx");
wb2.write(fileOut2);
fileOut2.close();
wb2.close();
}
二、 创建工作表
@Test
public void createExce2() throws Exception {
Workbook wb = new HSSFWorkbook();
wb.createSheet("new sheet");
wb.createSheet("second sheet");
String safeName = WorkbookUtil.createSafeSheetName("[O'Brien's sales*?]s"); // returns " O'Brien's sales "
wb.createSheet(safeName); FileOutputStream fileOut = new FileOutputStream("excel/workbook1.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAABPCAIAAACSzqDfAAAI+UlEQVR4nO2dT04bSRyFfSBWcwTfgAUsek7RbHMAs2DBgiUeZjOCDZqxpVkww8hsHIhQoihKFBAEUIQSRZGluQGzKLu72l3d7iJtv+qe79Nb4PKfeq6feS5X/+v8W8zV4dbGxtbhlX1752x642xnI70xx3g8fmoy+NeCfy3411KX/07VZJ8P98wNwj0o8K8F/1rwbygI96vDrblkn2stm7gT7mLwrwX/WvBvcIf72c7GHLMgT+7JRz/hHgr414J/Lfg3FC7L/AgMrhb8a8G/FvwbCHcH+NeCfy3410K4LxH8a8G/FvxrqS3cJ5PJ9+/fv3379vXr1y9fvjw+Pn7+/Pnh4eH+/v7Tp083NzfX19cfP3788OHD+/fv37179/bt2zdv3rx+/fry8vLVq1fn5+cvX74cAwBASDBzd4B/LfjXgn8tdfkn3B3gXwv+teBfC+G+RPCvBf9a8K9l+eF+dbiV36W90m7uhLsY/GvBvxb8G4rC3ToCNfnz6nBr1ug+gpVwDwP8a8G/FvwbCsL9bMfK7tkNZyPhHh7414J/Lfg3VFlzLwp3ThwWKPjXgn8t+DcsDvezndkKu7UsYxbfCfcwwb8W/GvBv2FBuM+f+DfZoLpzyCl/gwX/WvCvBf+GsnB3nNI9cydr7oGCfy3414J/g8/FOubv5nzugYJ/LfjXgn+Dz8U6ql6rg3AXg38t+NeCf4PfxTqcBzYR7qGBfy3414J/A6cfcIB/LfjXgn8thPsSwb8W/GvBvxbCfYngXwv+teBfS23hzsU6AADaBzN3B/jXgn8t+NdSl3/C3QH+teBfC/61EO5LBP9a8K8F/1qWH+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Ls6cgfo7u7h+vrm9HQ0GP55ejq6vr6R+0EINV0duQN0d/fw9+no9z+GRn+f/iP3gxBquv4DEfwEhVU/GC4AAAAASUVORK5CYII=" alt="" />
注意: sheet name is Excel must not exceed 31 characters and must not contain any of the any of the following characters:
0x0000
0x0003
colon (:)
backslash (\)
asterisk (*)
question mark (?)
forward slash (/)
opening square bracket ([)
closing square bracket (])
You can use org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)} for a safe way to create valid names, this utility replaces invalid characters with a space (' ')
三、 创建单元格
@Test
public void createExce3() throws Exception {
Workbook wb = new HSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet"); // Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow((short) 0);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1); // Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true); // Write the output to a file
FileOutputStream fileOut = new FileOutputStream("excel/workbook2.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhoAAAA4CAIAAAA0IMZlAAAIqklEQVR4nO2dy24aSRSGyRsls+Qtosir2bOcBVJeYsLCi+xmljNCmt1sENFIERsMNjYEYqCtjvEVx5Ejq9+AWdhAX6qhmq5Tp4/r/1QLG0Px1emm/u4uA6UFoGQ0mtzczNG2ttFowr2tAAC5KI1GEzTSxj5Ti2jsmwkNDS1nK7HPI2hoaGhoL6AhTtDQ0NDQDLRSkJufP3/m74SRx8fH6d1Abpvc9rlL6ASPj4/cCrmAPy8u+BuIkx8/fuTvhJGHhwf2SMjTxtcn3CV0goeHB26FXMCfFxf8DcTJ9+/f83fCyP39PXsk5GlfLxAnNri/v+dWyAX8eXHB30CczOfz/J2k4dWre3vVukf3DMHt7a35WX76/u2H0psPr0Lt3V80cTI6Pyasj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/x5ccEfceLEZgb5kV5n+PPigj/ixInNDPIjvc7w58UF/0ScPH1C/Yv9vhMF8Ac6SK8z/HlxwT8WJ63a3l6tFf8RcVJkpPtLQXqd4c+LC/7ROIl8pa/u9/u6UKYiI91fCtLrDH9eXPDfsHaCOJGBdH8pSK8z/HlxwT81Tlo13dUTF8pUZKT7S0F6neHPiwv+6jjx6lUsxUtBur8UpNcZ/ry44K+Ik0xZgjhhR7q/FKTXGf68uOAfj5OsWYI4YUe6vxSk1xn+vLjgH42TLF9zgjgpCNL9pSC9zvDnxQX/SJy0ansxdN544kKZiox0fylIrzP8eXHBHx+y4sRmBvmRXmf48+KCP+LEic0M8iO9zvDnxQV/xIkTmxnkR3qd4c+LC/74+iwAAAAGwNmJE0cNID/S6wx/Xlzw/x87LAer1hLrIAAAAABJRU5ErkJggg==" alt="" />
四、 创建时间单元格
@Test
public void createExce4() throws Exception {
Workbook wb = new HSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet"); // Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow(0); // Create a cell and put a date value in it. The first cell is not
// styled
// as a date.
Cell cell = row.createCell(0);
cell.setCellValue(new Date()); // we style the second cell as a date (and time). It is important to
// create a new cell style from the workbook otherwise you can end up
// modifying the built in style and effecting not only this cell but
// other cells.
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat(createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
cell = row.createCell(1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle); // you can also set date as java.util.Calendar
cell = row.createCell(2);
cell.setCellValue(Calendar.getInstance());
cell.setCellStyle(cellStyle); // Write the output to a file
FileOutputStream fileOut = new FileOutputStream("excel/workbook3.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAc0AAAA1CAIAAACskSeKAAAHdElEQVR4nO2dS3LiMBCGfS7uwRV8AM7hBbfgBi6W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Hx8fHR19/fG3AACw9+B6lhmIJg6EjBeJ+sNnmYFo4kDIeJGoP3yWGYgmDoSMF4n62312+2BEP54/u8dANHEgZLxI1N/ms7NoOIxm5p/wWedANHEgZLxI1N/is9qv1bT96RqJ588ORBMHQsaLRP3b3J+Fz/YIRBMHQsaLRP2bfXYWtb1DK/H82YFo4kDIeJGof4PPJpMR3gfrFYgmDoSMF4n61/lsJ5OFz+4GRBMHQsaLRP3rf++2g8nCZ3cDookDIeNFov4Wn+3y2Fn47FeAaOJAyHiRqD/ts7NoaNDmA7QSz58diCYOhIwXifrje7fMQDRxIGS8SNT/Hw4tV/FJpfhKAAAAAElFTkSuQmCC" alt="" />
五、 不同类型的单元格
@Test
public void createExce5() throws Exception {
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet");
Row row = sheet.createRow((short) 2);
row.createCell(0).setCellValue(1.1);
row.createCell(1).setCellValue(new Date());
row.createCell(2).setCellValue(Calendar.getInstance());
row.createCell(3).setCellValue("a string");
row.createCell(4).setCellValue(true);
row.createCell(5).setCellType(Cell.CELL_TYPE_ERROR); // Write the output to a file
FileOutputStream fileOut = new FileOutputStream("excel/workbook4.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAd4AAABUCAIAAACjoMGeAAAKqElEQVR4nO2dv3LiSh6F2Te6uyFvcQOizRVuQNV9iXsV8ACbbhFvQrF1ExIMNjYefI0tl2YY48E2HmZq9AazgfjTkrpBQvrpoPb5igAL0frUah21GkmuBTK8vb0JlVwOq9UKrZAL+mOxwP/+5bq6r+nTFboKc7FarWpCRb++vgqVXA7L5RKtkAv6Y7HAHx6veV5/fa52NC+XS6lofn5+Fio5CAKv3Ww0mm1PbgnBYrEovlCv3WzEcHvFLyYIhPxDImtRKf+q17/GX2o/WCwWIqF5/9uvf9T+/sff1Ne/hsUv6ObTpUCthPRc+Qa0WCykovnp6Umo5CDw2s2m6zZFs3k+nxdfqN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fC/2xMJqN0B8L/bHQHwtv1DZCfyz0x0J/LIxmI/THQn8s9MfCaDZCfyz0x0J/LH0+Sp8QQk6Q/wPwOSx8ThXWPgAAAABJRU5ErkJggg==" alt="" />
六、 边框的使用
@Test
public void createExce6() throws Exception {
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet");
Row row = sheet.createRow(1); // Create a cell and put a value in it.
Cell cell = row.createCell(1);
cell.setCellValue(4); // Style the cell with borders all around.
CellStyle style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.GREEN.getIndex());
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.BLUE.getIndex());
style.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
cell.setCellStyle(style); // Write the output to a file
FileOutputStream fileOut = new FileOutputStream("excel/workbook5.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPIAAABECAIAAAA0mf+bAAAFZ0lEQVR4nO2dO3PaTBSGlX8UvpJ/4fG4Sk+ZQjPuUxsKF+ncJsNMOjeM0mRoBAKBsAgXMbIxF3EzGO8/IIUdbtpJpKzOHvTpPLOFkT2rdzWPV4tWKynj8YQKlf9ZURgMq9UKqGY5rNdr7AhCrNfr7rQR39LxLJHmQ2m9WCyAapbDcrnEjiDEcrlEV1OktEd1keZDaT2bzYBqlsN8PseOIMR8PkdXU6T8fDxJrSeTCVDNjDEnr15cqHkHbg/M87zoK3Xy6sURuWL0u2GMMc/zoJzrXp5llVT2XSr7LpU9/wKzl+ZDTaT5UFqPRiOgmhlz8qqay6mgXg+Hw+grdfLq4X+jk1eBzB4OhyBOG+ep7Pur7tvHH9/fA5ltu6ZI86PUWtO07c+DwSDCmg8o5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oXc0FH16S1HNzrdPrapbH1ESG0DvU2RNJaBm9S01fGY4JqHfYNn6S1BAoZJVPYbDak9THBH6gQ7gnjpDU8hYx/xvxNc9I6kNShn5pPWkuFeutD/q7169Ocwr6nm7SWCml9CE2e84mZ1j5Ia9KaA2mNC2kNAmmNi6jWtIyAi/LpD3fwx4IN9iHEhHprPpQfF8H8pDUfyo8LaQ0C5cdFita7a9dJuSeE8uMCr/X+++YTs4yA8uMieRCSlPutKT8uUrV28ir11rEg4fkDa/22SpfG1vEg4fmpt+ZD+XGhsTUIlB8X0hoEyo8LvNZ7F/WCryhI+GFFJ+H5Q7xFN/ASAtIan4Tnp8lzPpQfF9IaBMqPi2D+X25T8t+TI6LEAAAAAElFTkSuQmCC" alt="" />
七、合并单元格
@Test
public void createExce7() throws Exception {
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet"); Row row = sheet.createRow((short) 1);
Cell cell = row.createCell((short) 1);
cell.setCellValue("This is a test of merging"); sheet.addMergedRegion(new CellRangeAddress(1, // first row (0-based)
1, // last row (0-based)
1, // first column (0-based)
2 // last column (0-based)
)); // Write the output to a file
FileOutputStream fileOut = new FileOutputStream("excel/workbook6.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZUAAABHCAIAAABAuE38AAAH5ElEQVR4nO2dv3LaShTGyRvFt+QtMhlXt6dMwUxeIqagSJc2d5hJl4Yhc2cyNBhsDARiQB7F2MaAITjOvkFSBPT3GK+QVquT/X5zCiOk1cdyzufdRYjc7e0cgUAgOEZOuwIEAoHYL3JCDff394paToeHhwfdEmLx8PAwXvQQiN0xmnV1p2osVPnXarVS1HI6rNdr3RJisV6vtdcGIvsxnHZ0p2osVPnX3d2dopbTYblc6pYQi+Vyqb02ENmPr1fwL4r5fK6oZSGEVSkeHhYrlroziNlslnyjVqV4GKBUT/40Qggxm82010aGYvz6xVHu4OjZwdGzg6OX77XryUwMLs+ST74U81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pAO3PNE2r82P+GB9S8ecNcP0oF7nmD8RQP9wAS45wnWv2igH5gA9zyBf9FAPzAB7nki9/tp2zmj/K0MufcL9AMT4J4n8vePlr93IfxLP9z1g3Tgnif4/hAN9AMT4J4n8C8a6AcmwD1P4F800A9MgHue4P6FAACuYPxFA/3ABLjnyW8Y7E8Z+NrrkAAAAABJRU5ErkJggg==" alt="" />
八、 字体的设置
@Test
public void createExce8() throws Exception {
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet"); // Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow(1); // Create a new font and alter it.
Font font = wb.createFont();
font.setFontHeightInPoints((short) 24);
font.setFontName("Courier New");
font.setItalic(true);
font.setStrikeout(true); // Fonts are set into a style so create a new one to use.
CellStyle style = wb.createCellStyle();
style.setFont(font); // Create a cell and put a value in it.
Cell cell = row.createCell(1);
cell.setCellValue("This is a test of fonts");
cell.setCellStyle(style);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("excel/workbook7.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiwAAABaCAIAAAAU8ZpLAAAMR0lEQVR4nO2du1IbSRuGtXcEf8hduFxEmxMSqMo3YRQQkDndLVU5c0KJhFKCDugEsiSGXzZgcTZgdAezgUBImtZM93R//XUz71MTeLWgebr7m37n0BK5y8trbNiwYcOGjWXLsRtgw4YNG7bMbrkxDY+Pjyc3HX+3wVWbqGfs8OfPH24FLeDPC/x5yZQ/VQjd39+zB4nO1h+1iHrGDg8PD9wKWsCfF/jzkil/qhC6vb1lDxKd7fu53yF0d3fHraAF/HmBPy+Z8qcKoevra7qE2N9bWd1a+XxCGELdn03znRIU8+sLFMrmdzMej8dXV1c0b7zQCq/8fe9/gf/6er4YmN8TWf2ImkAxBoT1Py4X6AuIrH7myyX6iiGU/KlCaDQakSXEt89fVja/rnzY+0YXQsfDhvlOiQx5UMwTlfGvX78I3nVyAL41wT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6NaVqWiKy8TtLOBQJhtDAHuXbmPS9upF3SnguJLlbzcpBCBnAd38AAOACIWQA3/0BAIALhJABfPcHAAAuEEIG8N0fAAC4QAgZwHd/AADgAiFkAN/9AQCAC4SQAXz3BwAALhBCBvDdHwAAuEAIGcB3fwAA4EIthJ6fn5+enh4eHu7v729vb29ubq6urkaj0cXFxfn5+c+fP4fD4enp6cnJSb/f7/V63W736Oio3W63Wq1Go1Gv16vVaqVSOQAAAAAUwZWQGPjzAn9e4M9LpvwRQmLgzwv8eYE/L5nyRwiJgT8v8OcF/rxkyl8uhMqF9RfyxQAh5AHw5wX+vMCfF9MhFBTz64XyWxq9/hsh5DDw5wX+vMCfF9LbceWC3MVQpjrRQeDPC/x5gT8vhCEUFPO4EvIC+PMCf17gzwtNCAXFPJ4J+QP8eYE/L/DnBVdCBoA/L/DnBf68ZMofz4TEwJ8X+PMCf14y5Y8QEgN/XuDPC/x5yZS/RAjNLMsOinnJp0KZ6kQHgT8v8OcF/rwo+f8H8EmBCP5X6ZEAAAAASUVORK5CYII=" alt="" />
九、 读或重写工作表
@Test
public void createExce9() throws Exception {
InputStream inp = new FileInputStream("excel/workbook4.xls"); Workbook wb = WorkbookFactory.create(inp);
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(2);
Cell cell = row.getCell(3);
if (cell == null)
cell = row.createCell(3);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("a test"); // Write the output to a file
FileOutputStream fileOut = new FileOutputStream("excel/workbook8.xls");
wb.write(fileOut);
fileOut.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdUAAABJCAIAAADkCCssAAAKZklEQVR4nO2dy1IiSRSGmTfSWfIWRoer2bN0QUS/ROvChbvezgQRvesNgTERhhu5X6Sa61Q30qgorba8AbPAgrpkQgF1ziHx/yIXWhTFl1WHnyQLitgEsGNZrdvbe7SlzbJa0scKAEJiltVC42/i0WZEEz9MaGikLSb+HENDQ0N7nw35i4aGhibTYm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hKI6N6mzVqh1V+OuHv85jLovf2cEOGq7fo50f/66FKf3XAX9Z4C8L/HlA/qqBvyzwlwX+PCB/1cBfFvjLAn8ecP11AACQAeNfNfCXBf6ywJ+H/wHFe5sxbtti5wAAAABJRU5ErkJggg==" alt="" />
十、 单元格换行
@Test
public void createExce10() throws Exception {
Workbook wb = new XSSFWorkbook(); // or new HSSFWorkbook();
Sheet sheet = wb.createSheet(); Row row = sheet.createRow(2);
Cell cell = row.createCell(2);
cell.setCellValue("Use \n with word wrap on to create a new line"); // to enable newlines you need set a cell styles with wrap=true
CellStyle cs = wb.createCellStyle();
cs.setWrapText(true);
cell.setCellStyle(cs); // increase row height to accomodate two lines of text
row.setHeightInPoints((2 * sheet.getDefaultRowHeightInPoints())); // adjust column width to fit the content
sheet.autoSizeColumn((short) 2); // Write the output to a file
FileOutputStream fileOut = new FileOutputStream("excel/workbook9.xlsx");
wb.write(fileOut);
fileOut.close();
wb.close();
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkwAAABvCAIAAACRoQglAAAIbElEQVR4nO3dbVbiSBSHcWZJM3vh0yxp1jF7YAOIckDkXegoCNLQoOAOmA+e5mSAFFWX5KaoPL9zTx+NIVWXjvkbMaG0h7pOZzCfL266oug1il6zHqXTGeT9fwXgtpXynkARBRByOkXIAbgSIZcDQo6QA6Cj1OkMKP3KPT9uonL/b6Io6tarlPuBjKIoiqIyKkKOoiiKCrZKX9n7+PhQGEXfdrvNewqZ2G63w58tiqKoAEoj5NbrtcIo+jabTd5TyMRms8l9v6QoikqlNEJutVopjKIv4L5y3y8piqJSKY2QWywWCqPoC7iv3PdLiqKoVEoj5ObzucIo+mazWd5TyMRsNst9v6Qoikqlsgq5SqVy+Pjt7S2jUU6Vy2W1sSaTSdZDlE9kPeLX19dkMsl9v6SCrz//+SNeuc+HCrUyCblKpRIPOYUwONAMuSiKFEY56kihwSiKct8vqbDrKNUIOSq7Sj/kKr/FD5qpj3LWdwCo5dxoNFIYRT/kRq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vPzc7PZrNfr1Wq1XC4Xi8X7+/tsNptOp5PJ5OXlJYqi8Xg8Go2Gw2G/3+/1ep1Op91ut1qtx8fHRqNRr9cfHh5qtdrd3V0VAAA/cCYnR18A4DlCTo6+AMBzhJwcfQGA5wg5OfoCAM8RcnL0BQCek4RcuVwm5PbhhkGofQEoIEJOjr4AwHPOIVculwm5b/QFAJ5zC7nveCPkvtEXAHjOIeQO2UbIfaMvAPAcISdHXwDguf8Apgrj7gvCltAAAAAASUVORK5CYII=" alt="" />
友情链接
- 具体的学习见官方文档: http://poi.apache.org/spreadsheet/quick-guide.html#NewWorkbook
- 本文实例代码: http://pan.baidu.com/s/1bpG4Lm3
- pdf框架之IText的使用: Java三方---->pdf框架之IText的使用
Java三方---->excel框架之POI的使用一的更多相关文章
- Java三方---->pdf框架之IText的使用
在企业的信息系统中,报表处理一直占比较重要的作用t.通过在服务器端使用Jsp或JavaBean生成PDF报表,客户端采用超链接显示或下载得到生成的报表,这样就很好的解决了B/S系统的报表处理问题.今天 ...
- JAVA实现Excel的读写--poi
上一篇为大家介绍了通过xls.jar的方式生成Excel的方法,本篇就为大家再介绍一下通过poi方式实现Excel文件的读写操作,内容很简单,代码注释很清晰. 1.生成Excel文件: import ...
- Java生成excel导出文件(使用poi+JXL)
1.使用poi生成文件 package com.mi.entity; import java.util.Date; public class Student { private int id; pri ...
- Java操作Excel(使用POI)
背景说明 以前写过使用 JXL 操作Excel的例子,但JXL对于Excel 2007版本以后的文件(即扩展名为 .xlsx)无法读取,也找不到可以支持的包.所以,有时不得不用 POI 来操作Exce ...
- 使用JAVA导出EXCEL表格(POI)
一.POI概述 Jakarta POI 是一套用于访问微软格式文档的Java API.POI提供API给Java程序对Microsoft Office格式档案读和写的功能.在许多企业办公系统中,经常会 ...
- java操作excel(通过POI)
读取所有数据,并打印出来,表单名:testcase 定义实体类(说明:这里单纯打印读取的excel内容,未用到实体类,反射的时候才会用到实体类) package com.qzcsbj; /** * @ ...
- Java导出Excel表,POI 实现合并单元格以及列自适应宽度(转载)
POI是apache提供的一个读写Excel文档的开源组件,在操作excel时常要合并单元格,合并单元格的方法是: sheet.addMergedRegion(new CellRangeAddress ...
- Java三方---->Thumbnailator框架的使用
Thumbnailator是一个用来生成图像缩略图的 Java类库,通过很简单的代码即可生成图片缩略图,也可直接对一整个目录的图片生成缩略图.有了它我们就不用在费心思使用Image I/O API,J ...
- java 导出 excel 最佳实践,java 大文件 excel 避免OOM(内存溢出) excel 工具框架
产品需求 产品经理需要导出一个页面的所有的信息到 EXCEL 文件. 需求分析 对于 excel 导出,是一个很常见的需求. 最常见的解决方案就是使用 poi 直接同步导出一个 excel 文件. 客 ...
随机推荐
- ring0获取指定进程的PEB
#ifndef TYPEDEF_H #define TYPEDEF_H typedef PPEB (__stdcall *P_PsGetProcessPeb)(PEPROCESS); typedef ...
- 实践中更高效、实现起来相对简单的基于末尾坏字符原则的BM算法实现
之前网上看的若干算法,无非两个原则:坏字符原则.好后缀原则.按照算法所述实现了一个版本,但发现其效率还不如本文所述的实现方式.个人分析效率较低的原因可能是因为不断地向前找坏字符或者好后缀来确定跳跃距离 ...
- Win10如何显示系统托盘所有图标
最快就是小娜搜索通知 打开Win10“设置”,依次进入“系统 – 通知和操作”,设置界面如图: 点击“选择在任务栏上显示哪些图标”打开如图所示的界面:
- drupal 网址合集
Drupal7上传图片和文件重命名 http://drupalchina.cn/node/2168 Drupal 7 导入中文超时错误解决方法http://drupalchina.cn/node/17 ...
- C# HttpRequest基础连接已经关闭: 接收时发生意外错误
在c#中使用HttpWebRequest时,频繁请求一个网址时,过段时间就会出现“基础连接已经关闭: 接收时发生意外错误”的错误提示. 将webRequest的属性设置成下面的,经测试可以解决. we ...
- Configurations of Vim/GVim of dsp
Linux环境写到用户主目录下的.vimrc文件(没有则新建),Windows环境则为GVim安装目录下的_vimrc(没有则新建),内容如下: "分上下两屏 "sp " ...
- pyqt的多Button的点击事件的槽函数的区分发送signal的按钮。
关键函数:QPushButton的setObjectName()/objectName() 个人注解:按功能或者区域,将按钮的点击事件绑定的不同的槽函数上. from PyQt5.QtWidgets ...
- ceRNA 调控机制
ceRNA 不同于mRNA, lncRNA, ncRNA 等概念,其指的既不是某一种类型的RNA(比如mRNA, lncRNA), 也不是某一类的RNA(如ncRNA); ceRNA 其实指的是不同种 ...
- Unity3d之Shader开发介绍
Shader是为渲染管线中的特定处理阶段提供算法的一段代码.shader是伴随着可编程渲染管线出现的,它的出现使得游戏开发者可以对渲染过程加以控制,拥有更大的创作空间,因此Shader的出现可以看作是 ...
- asp.net mvc webconfig配置文件操作
读取web.config数据,可以不用编译.如发布后,非常有用web.config文件<configuration> <appSettings> <add key=&qu ...