{"id":50215,"date":"2025-07-30T22:11:35","date_gmt":"2025-07-30T14:11:35","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/50215.html"},"modified":"2025-07-30T22:11:35","modified_gmt":"2025-07-30T14:11:35","slug":"excel%e6%96%87%e4%bb%b6%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/50215.html","title":{"rendered":"Excel\u6587\u4ef6\u89e3\u6790"},"content":{"rendered":"<h3>\u4e00\u3001\u6982\u8ff0&#xff1a;<\/h3>\n<p id=\"uab940f13\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u8fc7\u7a0b\u4e2d&#xff0c;\u7ecf\u5e38\u9700\u8981\u4f7f\u7528Excel\u6587\u4ef6\u6765\u8fdb\u884c\u6570\u636e\u7684\u5bfc\u5165\u6216\u5bfc\u51fa\u3002\u6240\u4ee5&#xff0c;\u5728\u901a\u8fc7Java\u8bed\u8a00\u5b9e\u73b0\u6b64\u7c7b\u9700\u6c42\u7684\u65f6\u5019&#xff0c;\u5f80\u5f80\u4f1a\u9762\u4e34\u7740Excel\u6587\u4ef6\u7684\u89e3\u6790&#xff08;\u5bfc\u5165&#xff09;\u6216\u751f\u6210&#xff08;\u5bfc\u51fa&#xff09;\u3002\u5728Java\u6280\u672f\u751f\u6001\u5708\u4e2d&#xff0c;\u53ef\u4ee5\u8fdb\u884cExcel\u6587\u4ef6\u5904\u7406\u7684\u4e3b\u6d41\u6280\u672f\u5305\u62ec&#xff1a;Apache POI\u3001JXL\u3001Alibaba EasyExcel\u7b49\u3002Apache POI\u57fa\u4e8eDOM\u65b9\u5f0f\u8fdb\u884c\u89e3\u6790&#xff0c;\u5c06\u6587\u4ef6\u76f4\u63a5\u52a0\u8f7d\u5185\u5b58&#xff0c;\u6240\u4ee5\u901f\u5ea6\u8f83\u5feb&#xff0c;\u9002\u5408Excel\u6587\u4ef6\u6570\u636e\u91cf\u4e0d\u5927\u7684\u5e94\u7528\u573a\u666f\u3002JXL\u53ea\u652f\u6301Excel 2003\u4ee5\u4e0b\u7248\u672c&#xff0c;\u6240\u4ee5\u4e0d\u592a\u5e38\u89c1\u3002Alibaba EasyExcel\u91c7\u7528\u9010\u884c\u8bfb\u53d6\u7684\u89e3\u6790\u6a21\u5f0f&#xff0c;\u5c06\u6bcf\u4e00\u884c\u7684\u89e3\u6790\u7ed3\u679c\u4ee5\u89c2\u5bdf\u8005\u7684\u6a21\u5f0f\u901a\u77e5\u5904\u7406&#xff08;AnalysisEventListener&#xff09;&#xff0c;\u6240\u4ee5\u6bd4\u8f83\u9002\u5408\u6570\u636e\u4f53\u91cf\u8f83\u5927\u7684Excel\u6587\u4ef6\u89e3\u6790\u3002<\/p>\n<h3>\u4e8c\u30012. Apache POI&#xff1a;<\/h3>\n<p id=\"u17d0269c\">Apache POI\u662f\u7528Java\u7f16\u5199\u7684\u514d\u8d39\u5f00\u6e90\u7684\u8de8\u5e73\u53f0\u7684Java API&#xff0c;Apache POI\u63d0\u4f9b\u7ed9Java\u7a0b\u5e8f\u5bf9Microsoft Office\u683c\u5f0f\u6863\u6848\u8fdb\u884c\u8bfb\u5199\u529f\u80fd\u7684API\u5f00\u6e90\u7c7b\u5e93\u3002\u5b83\u5206\u522b\u63d0\u4f9b\u5bf9\u4e0d\u540c\u683c\u5f0f\u6587\u4ef6\u7684\u89e3\u6790<\/p>\n<h4>&#xff08;1&#xff09;HSSF &#xff0d; \u63d0\u4f9b\u8bfb\u5199Microsoft Excel\u683c\u5f0f\u6863\u6848\u7684\u529f\u80fd\u3002<\/h4>\n<h4>&#xff08;2&#xff09;XSSF &#xff0d; \u63d0\u4f9b\u8bfb\u5199Microsoft Excel OOXML\u683c\u5f0f\u6863\u6848\u7684\u529f\u80fd\u3002<\/h4>\n<h4>&#xff08;3&#xff09;HWPF &#xff0d; \u63d0\u4f9b\u8bfb\u5199Microsoft Word\u683c\u5f0f\u6863\u6848\u7684\u529f\u80fd\u3002<\/h4>\n<h4>&#xff08;4&#xff09;HSLF &#xff0d; \u63d0\u4f9b\u8bfb\u5199Microsoft PowerPoint\u683c\u5f0f\u6863\u6848\u7684\u529f\u80fd\u3002<\/h4>\n<h4>&#xff08;5&#xff09;HDGF &#xff0d; \u63d0\u4f9b\u8bfb\u5199Microsoft Visio\u683c\u5f0f\u6863\u6848\u7684\u529f\u80fd\u3002<\/h4>\n<h3>\u4e09\u3001XSSF\u89e3\u6790Excel\u6587\u4ef6&#xff1a;<\/h3>\n<p id=\"u6188ba89\">\u00a0 \u00a0HSSF\u7528\u4e8e\u89e3\u6790\u65e7\u7248\u672c&#xff08;*.xls&#xff09;Excel\u6587\u4ef6&#xff0c;\u7531\u4e8e\u65e7\u7248\u672c\u7684Excel\u6587\u4ef6\u53ea\u80fd\u5b58\u572865535\u884c\u6570\u636e&#xff0c;\u6240\u4ee5\u76ee\u524d\u5df2\u7ecf\u4e0d\u5e38\u7528\u3002\u6240\u4ee5\u76ee\u524d\u4e3b\u8981\u91c7\u7528XSSF\u8fdb\u884c\u65b0\u7248\u672c&#xff08;*.xlsx&#xff09;Exce\u6587\u4ef6\u7684\u89e3\u6790\u3002<\/p>\n<h4>1\u3001Workbook&#xff08;Excel\u6587\u4ef6&#xff09;&#xff1a;<\/h4>\n<p id=\"u1c30df44\">\u00a0 \u00a0 \u00a0 Workbook\u63a5\u53e3\u4ee3\u8868\u4e00\u4e2aExcel\u6587\u4ef6&#xff0c;\u7528\u4e8e\u521b\u5efa\u6216\u52a0\u8f7d&#xff08;\u89e3\u6790&#xff09;Excel\u6587\u4ef6\u3002\u5e38\u89c1\u5b9e\u73b0\u7c7b\u662fXSSFWorkbook\u3002<\/p>\n<h5>&#xff08;1&#xff09;\u521b\u5efaExcel\u6587\u4ef6<\/h5>\n<p>try (Workbook workbook &#061; new XSSFWorkbook();<br \/>\nFileOutputStream fos &#061; new FileOutputStream(&#034;c:\\\\\\\\test\\\\\\\\temp.xlsx&#034;)) {<br \/>\n    workbook.write(fos);<br \/>\n} catch (IOException e) {<br \/>\n    e.printStackTrace();<br \/>\n}<\/p>\n<h5>&#xff08;2&#xff09;\u52a0\u8f7d&#xff08;\u89e3\u6790&#xff09;Excel\u6587\u4ef6&#xff1a;<\/h5>\n<p>\/\/ \u8f93\u5165\u6d41<br \/>\nFileInputStream fis &#061; new FileInputStream(&#034;c:\\\\\\\\test\\\\\\\\1627356554991.xlsx&#034;);<\/p>\n<p>\/\/ Excel\u6587\u4ef6\u5bf9\u8c61<br \/>\nWorkbook workbook &#061; new XSSFWorkbook(fis);<\/p>\n<h4>2\u3001Sheet &#xff08;\u5de5\u4f5c\u7c3f&#xff09;&#xff1a;\u901a\u8fc7Workbook\u6765\u8fdb\u884c\u5de5\u4f5c\u7c3fSheet\u5bf9\u8c61\u7684\u83b7\u53d6\u6216\u521b\u5efa<\/h4>\n<h5>&#xff08;1&#xff09;\u00a0\u521b\u5efa\u5de5\u4f5c\u7c3f<\/h5>\n<p>\/\/ \u6309\u7167\u9ed8\u8ba4\u540d\u79f0\u521b\u5efa\u5de5\u4f5c\u7c3f<br \/>\nSheet sheet1 &#061; workbook.createSheet();<\/p>\n<p>\/\/ \u6309\u7167\u81ea\u5b9a\u4e49\u540d\u79f0\u521b\u5efa\u5de5\u4f5c\u7c3f<br \/>\nSheet sheet2 &#061; workbook.createSheet(&#034;\u81ea\u5b9a\u4e49\u5de5\u4f5c\u7c3f2&#034;);<\/p>\n<h5>&#xff08;2&#xff09;\u83b7\u53d6\u5de5\u4f5c\u7c3f&#xff1a;<\/h5>\n<p>\/\/ \u6309\u7167\u5de5\u4f5c\u7c3f\u4e0b\u6807\u83b7\u53d6Sheet<br \/>\nSheet sheet01 &#061; workbook.getSheetAt(0);<\/p>\n<p>\/\/ \u6309\u7167\u5de5\u4f5c\u7c3f\u540d\u79f0\u83b7\u53d6Sheet<br \/>\nSheet sheet02 &#061; workbook.getSheet(&#034;Sheet0&#034;);<\/p>\n<h5>&#xff08;3&#xff09;\u83b7\u53d6\u5de5\u4f5c\u7c3f\u7684\u6570\u91cf&#xff1a;<\/h5>\n<p>int n &#061; workbook.getNumberOfSheets();<\/p>\n<h4>4\u3001Row&#xff08;\u6570\u636e\u884c&#xff09;&#xff1a;\u901a\u8fc7Sheet\u6765\u8fdb\u884c\u6570\u636e\u884cRow\u5bf9\u8c61\u7684\u83b7\u53d6\u6216\u521b\u5efa<\/h4>\n<h5>&#xff08;1&#xff09;\u521b\u5efa\u6570\u636e\u884c&#xff1a;<\/h5>\n<p>Row row &#061; sheet.createRow(0);<\/p>\n<h5>&#xff08;2&#xff09;\u83b7\u53d6\u9996\u884c\u4e0b\u6807&#xff1a;<\/h5>\n<p>int first &#061; sheet.getFirstRowNum();<\/p>\n<h5>&#xff08;3&#xff09;\u83b7\u53d6\u5c3e\u884c\u4e0b\u6807&#xff1a;<\/h5>\n<p>int last &#061; sheet.getLastRowNum();<\/p>\n<h5>&#xff08;4&#xff09;\u83b7\u53d6\u4e0b\u6807\u6307\u5b9a\u884c&#xff1a;<\/h5>\n<p>Row row &#061; sheet.getRow(0);<\/p>\n<h5>&#xff08;5&#xff09;\u904d\u5386\u6240\u6709\u884c&#xff1a;<\/h5>\n<p>for(Row row : sheet) {<br \/>\n    System.out.println(row);<br \/>\n}<\/p>\n<h5>&#xff08;6&#xff09;\u904d\u5386\u6307\u5b9a\u533a\u57df\u884c&#xff1a;<\/h5>\n<p>for (int i &#061; 1; i &lt;&#061; sheet.getLastRowNum(); i&#043;&#043;) {<br \/>\n    Row row &#061; sheet.getRow(i);<br \/>\n    System.out.println(row);<br \/>\n}<\/p>\n<h4>5\u3001Cell&#xff08;\u5355\u5143\u683c&#xff09;&#xff1a;\u901a\u8fc7Row\u6765\u8fdb\u884c\u5355\u5143\u683cCell\u5bf9\u8c61\u7684\u83b7\u53d6\u6216\u521b\u5efa\u3002<\/h4>\n<h5>&#xff08;1&#xff09;\u521b\u5efa\u5355\u5143\u683c&#xff1a;<\/h5>\n<p>Cell cell0 &#061; row.createCell(0);<\/p>\n<h5>&#xff08;2&#xff09;\u8bbe\u7f6e\u5355\u5143\u683c\u503c&#xff1a;<\/h5>\n<p>cell0.setCellValue(UUID.randomUUID().toString());<\/p>\n<h5>&#xff08;3&#xff09;\u6839\u636e\u4e0b\u8868\u83b7\u53d6\u5355\u5143\u683c&#xff1a;<\/h5>\n<p>Cell cell &#061; row.getCell(1);<\/p>\n<h5>&#xff08;4&#xff09;\u904d\u5386\u6240\u6709\u5355\u5143\u683c&#xff1a;<\/h5>\n<p>for(Cell cell : row) {<\/p>\n<p>}<\/p>\n<h5>&#xff08;5&#xff09;\u83b7\u53d6\u5355\u5143\u683c\u7c7b\u578b&#xff1a;<\/h5>\n<p>CellType type &#061; cell.getCellType();<\/p>\n<h5>&#xff08;6&#xff09;\u8bbe\u7f6e\u5355\u5143\u683c\u6837\u5f0f&#xff1a;<\/h5>\n<p>\/\/ \u521b\u5efa\u5355\u5143\u683c\u6837\u5f0f<br \/>\nCellStyle headerCellStyle &#061; workbook.createCellStyle();<\/p>\n<p>\/\/\u8bbe\u7f6e\u5355\u5143\u683c\u7684\u6c34\u5e73\u5bf9\u9f50\u7c7b\u578b, \u6b64\u65f6\u6c34\u5e73\u5c45\u4e2d<br \/>\nheaderCellStyle.setAlignment(HorizontalAlignment.CENTER);<\/p>\n<p>\/\/ \u8bbe\u7f6e\u5355\u5143\u683c\u7684\u5782\u76f4\u5bf9\u9f50\u7c7b\u578b,\u6b64\u65f6\u5782\u76f4\u9760\u5e95\u8fb9<br \/>\nheaderCellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM);<\/p>\n<p>\/\/ \u521b\u5efa\u5e76\u8bbe\u7f6e\u5b57\u4f53<br \/>\nFont font &#061; workbook.createFont();<br \/>\nfont.setBold(true);<br \/>\nfont.setColor(Font.COLOR_RED);<br \/>\nheaderCellStyle.setFont(font);<\/p>\n<h5>&#xff08;7&#xff09;\u8bbe\u7f6e\u5355\u5143\u683c\u6570\u636e\u683c\u5f0f&#xff1a;<\/h5>\n<p>\/\/ \u521b\u5efa\u5355\u5143\u683c\u6837\u5f0f<br \/>\nDataFormat dataFormat &#061; workbook.createDataFormat();<br \/>\nShort formatCode &#061; dataFormat.getFormat(&#034;yyyy-MM-dd HH:mm:ss&#034;);<br \/>\nCellStyle cellStyle &#061; workbook.createCellStyle();<br \/>\ncellStyle.setDataFormat(formatCode);<\/p>\n<p>\/\/ &#8230;<\/p>\n<p>\/\/ \u4e3a\u5f53\u524d\u884c\u521b\u5efa\u5355\u5143\u683c<br \/>\nCell cell1 &#061; row.createCell(1);<br \/>\ncell1.setCellStyle(cellStyle); \/\/ \u8bbe\u7f6e\u5355\u5143\u683c\u6837\u5f0f<br \/>\ncell1.setCellValue(new Date()); \/\/ \u4fdd\u5b58\u5f53\u524d\u65e5\u671f\u65f6\u95f4\u81f3\u672c\u5355\u5143\u683c<\/p>\n<h5>&#xff08;8&#xff09;\u8bbe\u7f6e\u5355\u5143\u683c\u5bf9\u9f50&#xff1a;<\/h5>\n<p>\/\/ \u521b\u5efa\u5355\u5143\u683c\u6837\u5f0f<br \/>\nCellStyle cellStyle &#061; workbook.createCellStyle();<\/p>\n<p>\/\/\u8bbe\u7f6e\u5355\u5143\u683c\u7684\u6c34\u5e73\u5bf9\u9f50\u7c7b\u578b\u3002 \u6b64\u65f6\u6c34\u5e73\u5c45\u4e2d<br \/>\ncellStyle.setAlignment(HorizontalAlignment.CENTER);<\/p>\n<p>\/\/ \u8bbe\u7f6e\u5355\u5143\u683c\u7684\u5782\u76f4\u5bf9\u9f50\u7c7b\u578b\u3002 \u6b64\u65f6\u5782\u76f4\u9760\u5e95\u8fb9<br \/>\ncellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM);<\/p>\n<h3>\u56db\u3001\u8d85\u5927Excel\u6587\u4ef6\u8bfb\u5199<\/h3>\n<h4>1\u3001\u00a0\u4f7f\u7528POI\u5199\u51fa&#xff1a;\u4f7f\u7528SXSSFWorkbook\u8fdb\u884c\u5199\u5165&#xff0c;\u901a\u8fc7\u8bbe\u7f6eSXXFWorkbook\u7684\u6784\u9020\u53c2\u6570&#xff0c;\u53ef\u4ee5\u8bbe\u7f6e\u6bcf\u6b21\u5728\u5185\u5b58\u4e2d\u4fdd\u6301\u7684\u884c\u6570&#xff0c;\u5f53\u8fbe\u5230\u8fd9\u4e2a\u503c\u7684\u65f6\u5019&#xff0c;\u90a3\u4e48\u4f1a\u628a\u8fd9\u4e9b\u6570\u636eflush\u5230\u78c1\u76d8\u4e0a&#xff0c;\u8fd9\u6837\u5c31\u4e0d\u4f1a\u51fa\u73b0\u5185\u5b58\u4e0d\u591f\u7684\u60c5\u51b5\u3002<\/h4>\n<p>try (Workbook workbook &#061; new SXSSFWorkbook(100);<br \/>\nFileOutputStream fos &#061; new FileOutputStream(&#034;c:\\\\\\\\test\\\\\\\\temp.xlsx&#034;)) {<br \/>\n    Sheet sheet1 &#061; workbook.createSheet();<\/p>\n<p>    for (int i &#061; 0; i &lt;&#061; 1000000; i&#043;&#043;) {<br \/>\n        Row row &#061; sheet1.createRow(i);<br \/>\n        Cell cell0 &#061; row.createCell(0);<br \/>\n        cell0.setCellValue(UUID.randomUUID().toString());<\/p>\n<p>        Cell cell1 &#061; row.createCell(1);<br \/>\n        cell1.setCellValue(new Date());<br \/>\n    }<\/p>\n<p>    workbook.write(fos);<br \/>\n} catch (IOException e) {<br \/>\n    e.printStackTrace();<br \/>\n}<\/p>\n<h4>2\u3001\u4f7f\u7528EasyExcel&#xff1a;<\/h4>\n<h5>&#xff08;1&#xff09;\u51c6\u5907\u5b9e\u4f53\u7c7b&#xff1a;<\/h5>\n<p>public class Order {<br \/>\n    &#064;ExcelProperty(&#034;\u8ba2\u5355\u7f16\u53f7&#034;)<br \/>\nprivate String orderId; \/\/ \u8ba2\u5355\u7f16\u53f7<\/p>\n<p>    &#064;ExcelProperty(&#034;\u652f\u4ed8\u91d1\u989d&#034;)<br \/>\n&#064;NumberFormat(&#034;&#xffe5;#,###&#034;)<br \/>\nprivate Double payment; \/\/ \u652f\u4ed8\u91d1\u989d<\/p>\n<p>    &#064;ExcelProperty(value &#061; &#034;\u521b\u5efa\u65e5\u671f&#034;,converter &#061; LocalDateTimeConverter.class)<br \/>\nprivate LocalDateTime creationTime; \/\/ \u521b\u5efa\u65f6\u95f4<\/p>\n<p>public Order() {<br \/>\nthis.orderId &#061; LocalDateTime.now().format(DateTimeFormatter.ofPattern(&#034;yyyyMMddhhmmss&#034;))<br \/>\n&#043; UUID.randomUUID().toString().substring(0, 5);<br \/>\nthis.payment &#061; Math.random() * 10000;<br \/>\nthis.creationTime &#061; LocalDateTime.now();<br \/>\n}<\/p>\n<p>public String getOrderId() {<br \/>\nreturn orderId;<br \/>\n}<\/p>\n<p>public void setOrderId(String orderId) {<br \/>\nthis.orderId &#061; orderId;<br \/>\n}<\/p>\n<p>public Double getPayment() {<br \/>\nreturn payment;<br \/>\n}<\/p>\n<p>public void setPayment(Double payment) {<br \/>\nthis.payment &#061; payment;<br \/>\n}<\/p>\n<p>public LocalDateTime getCreationTime() {<br \/>\nreturn creationTime;<br \/>\n}<\/p>\n<p>public void setCreationTime(LocalDateTime creationTime) {<br \/>\nthis.creationTime &#061; creationTime;<br \/>\n}<\/p>\n<p>&#064;Override<br \/>\npublic String toString() {<br \/>\nreturn &#034;Order [orderId&#061;&#034; &#043; orderId &#043; &#034;, payment&#061;&#034; &#043; payment &#043; &#034;, creationTime&#061;&#034; &#043; creationTime &#043; &#034;]&#034;;<br \/>\n}<br \/>\n}<\/p>\n<h5>&#xff08;2&#xff09;\u3001\u51c6\u5907Converter\u8f6c\u6362\u7c7b&#xff08;\u517c\u5bb9LocalDateTime\u65e5\u671f\u65f6\u95f4\u7c7b&#xff09;&#xff1a;<\/h5>\n<p>public class LocalDateTimeConverter implements Converter&lt;LocalDateTime&gt; {<\/p>\n<p>&#064;Override<br \/>\npublic Class&lt;LocalDateTime&gt; supportJavaTypeKey() {<br \/>\nreturn LocalDateTime.class;<br \/>\n}<\/p>\n<p>&#064;Override<br \/>\npublic CellDataTypeEnum supportExcelTypeKey() {<br \/>\nreturn CellDataTypeEnum.STRING;<br \/>\n}<\/p>\n<p>&#064;Override<br \/>\npublic LocalDateTime convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,<br \/>\nGlobalConfiguration globalConfiguration) {<br \/>\nreturn LocalDateTime.parse(cellData.getStringValue(), DateTimeFormatter.ofPattern(&#034;yyyy-MM-dd HH:mm:ss&#034;));<br \/>\n}<\/p>\n<p>&#064;Override<br \/>\npublic CellData&lt;String&gt; convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty,<br \/>\nGlobalConfiguration globalConfiguration) {<br \/>\nreturn new CellData&lt;&gt;(value.format(DateTimeFormatter.ofPattern(&#034;yyyy-MM-dd HH:mm:ss&#034;)));<br \/>\n}<\/p>\n<p>}<\/p>\n<h4>3\u3001\u5199\u5165100w\u6761\u6570\u636e&#xff1a;<\/h4>\n<p>public class Demo {<br \/>\npublic static void main(String[] args) {<br \/>\n        \/\/ \u5199\u5165100w\u6761\u6570\u636e<br \/>\n        EasyExcel.write(&#034;c:\\\\\\\\test\\\\\\\\run\\\\\\\\easy.xlsx&#034;, Order.class)<br \/>\n                 .sheet(&#034;\u8ba2\u5355\u5217\u8868&#034;)<br \/>\n                 .doWrite(data());<br \/>\n    }<\/p>\n<p>    \/\/ \u521b\u5efa100w\u6761\u8ba2\u5355\u6570\u636e<br \/>\n    private static List&lt;Order&gt; data() {<br \/>\n        List&lt;Order&gt; list &#061; new ArrayList&lt;Order&gt;();<br \/>\n        for (int i &#061; 0; i &lt; 1000000; i&#043;&#043;) {<br \/>\n            list.add(new Order());<br \/>\n        }<br \/>\n        return list;<br \/>\n    }<br \/>\n}<\/p>\n<h4>4\u3001\u8bfb\u53d6100w\u6761\u6570\u636e&#xff1a;<\/h4>\n<p>\/\/ \u8bfb\u53d6100w\u6761\u6570\u636e<br \/>\nEasyExcel.read(&#034;c:\\\\\\\\test\\\\\\\\run\\\\\\\\easy.xlsx&#034;, Order.class,new AnalysisEventListener&lt;Order&gt;() {<br \/>\n    &#064;Override<br \/>\n    public void invoke(Order order, AnalysisContext arg1) {<br \/>\n        \/\/ \u8bfb\u53d6\u6bcf\u6761\u6570\u636e<br \/>\n        orderList.add(order);<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public void invokeHeadMap(Map&lt;Integer, String&gt; headMap, AnalysisContext context) {<br \/>\n        \/\/ \u8bfb\u53d6\u5230\u5217\u5934<br \/>\n        System.out.println(headMap);<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public void doAfterAllAnalysed(AnalysisContext arg0) {<br \/>\n        \/\/ \u8bfb\u53d6\u5b8c\u6bd5<br \/>\n        System.out.println(&#034;END&#034;);<br \/>\n    }<br \/>\n}).sheet().doRead();<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb463\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf7\u6b21\u3002Java\u4e2d\u5904\u7406Excel\u6587\u4ef6\u7684\u5e38\u7528\u5de5\u5177\u5305\u62ecApache POI\u548cEasyExcel\u3002Apache POI\u652f\u6301\u8bfb\u5199\u591a\u79cdOffice\u683c\u5f0f\u6587\u4ef6\uff0c\u5176\u4e2dXSSF\u7528\u4e8e\u5904\u7406\u65b0\u7248Excel(.xlsx)\uff0c\u901a\u8fc7Workbook\u3001Sheet\u3001Row\u548cCell\u9010\u5c42\u64cd\u4f5c\u6570\u636e\uff0c\u9002\u5408\u5c0f\u6587\u4ef6\u5904\u7406\u3002\u5bf9\u4e8e\u5927\u6587\u4ef6\uff0cPOI\u63d0\u4f9bSXSSFWorkbook\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u3002\u963f\u91cc\u5f00\u6e90\u7684EasyExcel\u91c7\u7528\u9010\u884c\u89e3\u6790\u6a21\u5f0f\uff0c\u901a\u8fc7\u76d1\u542c\u5668\u5904\u7406\u6570\u636e\uff0c\u663e\u8457\u964d\u4f4e\u5185\u5b58\u6d88\u8017\uff0c\u9002\u5408\u767e\u4e07\u7ea7\u6570\u636e\u7684\u5bfc\u5165\u5bfc\u51fa\u3002\u5f00\u53d1\u8005\u53ef\u6839\u636e\u6587\u4ef6\u5927\u5c0f\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\uff0c\u5c0f\u6587\u4ef6\u7528POI\u6548\u7387\u66f4\u9ad8\uff0c\u5927\u6587\u4ef6\u5219\u5efa\u8bae<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1374,99,4889,4890],"topic":[],"class_list":["post-50215","post","type-post","status-publish","format-standard","hentry","category-server","tag-excel","tag-java","tag-java-excel","tag-4890"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Excel\u6587\u4ef6\u89e3\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/50215.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Excel\u6587\u4ef6\u89e3\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb463\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf7\u6b21\u3002Java\u4e2d\u5904\u7406Excel\u6587\u4ef6\u7684\u5e38\u7528\u5de5\u5177\u5305\u62ecApache POI\u548cEasyExcel\u3002Apache POI\u652f\u6301\u8bfb\u5199\u591a\u79cdOffice\u683c\u5f0f\u6587\u4ef6\uff0c\u5176\u4e2dXSSF\u7528\u4e8e\u5904\u7406\u65b0\u7248Excel(.xlsx)\uff0c\u901a\u8fc7Workbook\u3001Sheet\u3001Row\u548cCell\u9010\u5c42\u64cd\u4f5c\u6570\u636e\uff0c\u9002\u5408\u5c0f\u6587\u4ef6\u5904\u7406\u3002\u5bf9\u4e8e\u5927\u6587\u4ef6\uff0cPOI\u63d0\u4f9bSXSSFWorkbook\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u3002\u963f\u91cc\u5f00\u6e90\u7684EasyExcel\u91c7\u7528\u9010\u884c\u89e3\u6790\u6a21\u5f0f\uff0c\u901a\u8fc7\u76d1\u542c\u5668\u5904\u7406\u6570\u636e\uff0c\u663e\u8457\u964d\u4f4e\u5185\u5b58\u6d88\u8017\uff0c\u9002\u5408\u767e\u4e07\u7ea7\u6570\u636e\u7684\u5bfc\u5165\u5bfc\u51fa\u3002\u5f00\u53d1\u8005\u53ef\u6839\u636e\u6587\u4ef6\u5927\u5c0f\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\uff0c\u5c0f\u6587\u4ef6\u7528POI\u6548\u7387\u66f4\u9ad8\uff0c\u5927\u6587\u4ef6\u5219\u5efa\u8bae\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/50215.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-30T14:11:35+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50215.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/50215.html\",\"name\":\"Excel\u6587\u4ef6\u89e3\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-30T14:11:35+00:00\",\"dateModified\":\"2025-07-30T14:11:35+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/50215.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/50215.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50215.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel\u6587\u4ef6\u89e3\u6790\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Excel\u6587\u4ef6\u89e3\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/50215.html","og_locale":"zh_CN","og_type":"article","og_title":"Excel\u6587\u4ef6\u89e3\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb463\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf7\u6b21\u3002Java\u4e2d\u5904\u7406Excel\u6587\u4ef6\u7684\u5e38\u7528\u5de5\u5177\u5305\u62ecApache POI\u548cEasyExcel\u3002Apache POI\u652f\u6301\u8bfb\u5199\u591a\u79cdOffice\u683c\u5f0f\u6587\u4ef6\uff0c\u5176\u4e2dXSSF\u7528\u4e8e\u5904\u7406\u65b0\u7248Excel(.xlsx)\uff0c\u901a\u8fc7Workbook\u3001Sheet\u3001Row\u548cCell\u9010\u5c42\u64cd\u4f5c\u6570\u636e\uff0c\u9002\u5408\u5c0f\u6587\u4ef6\u5904\u7406\u3002\u5bf9\u4e8e\u5927\u6587\u4ef6\uff0cPOI\u63d0\u4f9bSXSSFWorkbook\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u3002\u963f\u91cc\u5f00\u6e90\u7684EasyExcel\u91c7\u7528\u9010\u884c\u89e3\u6790\u6a21\u5f0f\uff0c\u901a\u8fc7\u76d1\u542c\u5668\u5904\u7406\u6570\u636e\uff0c\u663e\u8457\u964d\u4f4e\u5185\u5b58\u6d88\u8017\uff0c\u9002\u5408\u767e\u4e07\u7ea7\u6570\u636e\u7684\u5bfc\u5165\u5bfc\u51fa\u3002\u5f00\u53d1\u8005\u53ef\u6839\u636e\u6587\u4ef6\u5927\u5c0f\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\uff0c\u5c0f\u6587\u4ef6\u7528POI\u6548\u7387\u66f4\u9ad8\uff0c\u5927\u6587\u4ef6\u5219\u5efa\u8bae","og_url":"https:\/\/www.wsisp.com\/helps\/50215.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-30T14:11:35+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/50215.html","url":"https:\/\/www.wsisp.com\/helps\/50215.html","name":"Excel\u6587\u4ef6\u89e3\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-30T14:11:35+00:00","dateModified":"2025-07-30T14:11:35+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/50215.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/50215.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/50215.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Excel\u6587\u4ef6\u89e3\u6790"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=50215"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50215\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=50215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=50215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=50215"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=50215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}