alibaba / easyexcel Goto Github PK
View Code? Open in Web Editor NEW快速、简洁、解决大文件内存溢出的java处理Excel工具
Home Page: https://easyexcel.opensource.alibaba.com
License: Apache License 2.0
快速、简洁、解决大文件内存溢出的java处理Excel工具
Home Page: https://easyexcel.opensource.alibaba.com
License: Apache License 2.0
@ExcelProperty(value = "处理时间", index = 13,format = "yyyy-MM-dd HH:mm:ss")
我看这里有一句代码:
例如:我有一个excel模板(很多格式之类的都在模板里面做), 然后用easyexcel 用调用这个模板吗?
然后向模板 写入数据 吗?
目前,从RowModel中获取字段的方式是使用getDeclaredFields
,这会导致只能获取到该类的字段,获取不到从父类继承下来的字段。该代码位于/com/alibaba/excel/metadata/ExcelHeadProperty.java
/**
* 初始化每列
*/
private void initColumnProperties() {
if (this.headClazz != null) {
Field[] fields = this.headClazz.getDeclaredFields();
List<List<String>> headList = new ArrayList<List<String>>();
for (Field f : fields) {
initOneColumnProperty(f);
}
//对列排序
Collections.sort(columnPropertyList);
if (head == null || head.size() == 0) {
for (ExcelColumnProperty excelColumnProperty : columnPropertyList) {
headList.add(excelColumnProperty.getHead());
}
this.head = headList;
}
}
}
有时会有一种需求,即根据用户输入的不同,输出字段有略微差异的表。比如,导出某公司所有员工的表时,根据操作用户的权限,部分员工(如人力资源部门的员工)可以看到工资字段,而其他员工看不到。这时,使用继承,将所有员工都可以看到的字段放到父类里面去,将特殊员工才能看到的字段放到子类里面,根据操作对象返回不同的类,是解决这一问题的一种方法。因此,获取父类继承下来的字段在有些时候是比较有用的。使用commons包里面的反射函数,可以很方便地获取到从父类继承下来的字段
数据使用mac版本的office新建的excel,读取有问题,拿到windows系统也读取有问题。用windows系统创建的excel,在mac上读取无问题。
15:35:09.799 [main] INFO cn.com.service.ExcelService - 当前sheet:1 当前行:0 data:[姓名, xing'ming, 性别, ingbie, 职能, zhi'nneg, 手机, null, null, null, null, null, null, null, null, null, null, null, null, null]
15:35:09.806 [main] INFO cn.com.service.ExcelService - 当前sheet:1 当前行:1 data:[出生日期, shou'ji, 邮箱, you'xiang, chu'shegn'ri'qi, 固定电话, gu'ding'dian'hua, null, null, null, null, null, null, null, null, null, null, null, null, null]
15:35:09.807 [main] INFO cn.service.ExcelService - 当前sheet:1 当前行:2 data:[null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]
如题,如何给某个cell添加超链接?
poi是可以的,如下代码所示:
cell = row.createCell(colNumber)。 cell.setCellType(HSSFCell.CELL_TYPE_FORMULA); cell.setCellFormula("HYPERLINK(\"" + "Http://www.google.ca"+ "\",\"" + "Google Canada"+ "\")"); 或cell.setCellFormula("HYPERLINK(\"[workbook.xls]'sheet2'!A1\",\"homepage\")"); //HYPERLINK("#明细!A1","homepage")
我查看了一下源代码,好像没有把这个功能带过来,也就是没有实现。
写Excel 每行数据是List无表头 中
应该调用writer.write0()方法,文档中使用了writer.write()方法。
我看ExcelBuilderImpl.addContent()方法里面有
int rowNum = this.context.getCurrentSheet().getLastRowNum();
这么一个方法,但是我读取已经保存好的Excel,结果rowNum还是从0开始,这个地方可以帮忙看下吗?
我这边的测试方法是,对同一个Excel,执行多次输出。
com.alibaba.excel.read.exception.ExcelAnalysisException: com.alibaba.excel.read.exception.ExcelAnalysisException: java.lang.IndexOutOfBoundsException: Index: 882, Size: 882 at com.alibaba.excel.read.SaxAnalyserV07.execute(SaxAnalyserV07.java:85) at com.alibaba.excel.read.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:51) at com.alibaba.excel.read.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:45) at com.alibaba.excel.ExcelReader.read(ExcelReader.java:64) at read.v07.Read2007Xlsx.withModelMultipleSheet(Read2007Xlsx.java:151) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: com.alibaba.excel.read.exception.ExcelAnalysisException: java.lang.IndexOutOfBoundsException: Index: 882, Size: 882 at com.alibaba.excel.read.SaxAnalyserV07.parseXmlSource(SaxAnalyserV07.java:117) at com.alibaba.excel.read.SaxAnalyserV07.execute(SaxAnalyserV07.java:73) ... 26 more Caused by: java.lang.IndexOutOfBoundsException: Index: 882, Size: 882 at java.util.LinkedList.checkElementIndex(LinkedList.java:555) at java.util.LinkedList.get(LinkedList.java:476) at com.alibaba.excel.read.v07.RowHandler.endCellValue(RowHandler.java:111) at com.alibaba.excel.read.v07.RowHandler.endElement(RowHandler.java:131) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2967) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643) at com.alibaba.excel.read.v07.XmlParserFactory.parse(XmlParserFactory.java:28) at com.alibaba.excel.read.SaxAnalyserV07.parseXmlSource(SaxAnalyserV07.java:109) ... 27 more
电脑mac High Sierra,读取的是xlsx.
报错信息:
java.io.FileNotFoundException: /var/folders/4c/kjkl6r0s5qgglzswfzjkl6sh0000gn/T/easyexcel/-4268776904857236582/xl/worksheets/sheet3.xml (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at com.alibaba.excel.read.SaxAnalyserV07$1.startElement(SaxAnalyserV07.java:178)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1339)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.alibaba.excel.read.v07.XmlParserFactory.parse(XmlParserFactory.java:28)
at com.alibaba.excel.read.SaxAnalyserV07.initSheetSourceList(SaxAnalyserV07.java:166)
at com.alibaba.excel.read.SaxAnalyserV07.start(SaxAnalyserV07.java:151)
at com.alibaba.excel.read.SaxAnalyserV07.<init>(SaxAnalyserV07.java:61)
at com.alibaba.excel.read.ExcelAnalyserImpl.getSaxAnalyser(ExcelAnalyserImpl.java:28)
at com.alibaba.excel.read.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:49)
at com.alibaba.excel.ExcelReader.read(ExcelReader.java:55)
AnalysisEventListener 这个类使用泛型 AnalysisEventListener之后就不做处理了, invoke的参数Object回来是个集合
首先感谢作者开源此工具。用起来确实很方便
刚编写的Issues不小心点了关闭,重新发下。
模板中这样写没问题
@ExcelProperty(value = {"协议支付","本期新增客户数量"},index = 1)
private String p2;
@ExcelProperty(value = {"协议支付","本期减少客户数量"},index = 2)
private int p3;
@ExcelProperty(value = {"协议支付","本期净增客户数量"},index = 3)
private long p4;
@ExcelProperty(value = {"协议支付","累计签约客户数量"},index = 4)
private String p5;
@ExcelProperty(value = {"商业委托支付","上期末存量客户数量1"},index = 5)
private String p6;
@ExcelProperty(value = {"商业委托支付","本期新增客户数量1"},index = 6)
private String p7;
@ExcelProperty(value = {"商业委托支付","本期减少客户数量1"},index = 7)
private String p8;
@ExcelProperty(value = {"商业委托支付","本期净增客户数量1"},index = 8)
private String p9;
@ExcelProperty(value = {"商业委托支付","累计签约客户数量1"},index = 9)
private String p10;
但是这样写就报错
@ExcelProperty(value = {"协议支付","本期新增客户数量"},index = 1)
private String p2;
@ExcelProperty(value = {"协议支付","本期减少客户数量"},index = 2)
private int p3;
@ExcelProperty(value = {"协议支付","本期净增客户数量"},index = 3)
private long p4;
@ExcelProperty(value = {"协议支付","累计签约客户数量"},index = 4)
private String p5;
@ExcelProperty(value = {"商业委托支付","上期末存量客户数量"},index = 5)
private String p6;
@ExcelProperty(value = {"商业委托支付","本期新增客户数量"},index = 6)
private String p7;
@ExcelProperty(value = {"商业委托支付","本期减少客户数量"},index = 7)
private String p8;
@ExcelProperty(value = {"商业委托支付","本期净增客户数量"},index = 8)
private String p9;
@ExcelProperty(value = {"商业委托支付","累计签约客户数量"},index = 9)
private String p10;
错误信息:
java.lang.IllegalStateException: Cannot add merged region B2:G2 to sheet because it overlaps with an existing merged region (A2:F2).
at org.apache.poi.xssf.usermodel.XSSFSheet.validateMergedRegions(XSSFSheet.java:432)
at org.apache.poi.xssf.usermodel.XSSFSheet.addMergedRegion(XSSFSheet.java:369)
at org.apache.poi.xssf.usermodel.XSSFSheet.addMergedRegion(XSSFSheet.java:323)
at org.apache.poi.xssf.streaming.SXSSFSheet.addMergedRegion(SXSSFSheet.java:390)
at com.alibaba.excel.write.context.GenerateContextImpl.appendHeadToExcel(GenerateContextImpl.java:122)
at com.alibaba.excel.write.context.GenerateContextImpl.buildCurrentSheet(GenerateContextImpl.java:101)
at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:52)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:52)
at function.write.ExcelWriteIndexTest.testDaTong(ExcelWriteIndexTest.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
如果必须不能重复,是否可以考虑引入Alias,毕竟名字重复列很正常,或者说我用的不对,烦请说明。
读取一个50几M的excel文件(这个文件也是用easyexcel生成的),在执行read方法时,还是会产生OOM
首先说明一下;
字段比较多,30个多,excel文件12w行多;基本都是String类型,部分String还是特别长那种。
CurrentName:workbook
CurrentName:fileVersion
CurrentName:workbookPr
CurrentName:mc:AlternateContent
CurrentName:mc:Choice
CurrentName:x15ac:absPath
CurrentName:bookViews
CurrentName:workbookView
CurrentName:sheets
CurrentName:3
CurrentName:name
CurrentName:sheetId
CurrentName:r:id
CurrentName:calcPr
CurrentName:extLst
CurrentName:ext
CurrentName:x15:workbookPr
09:46:01.038,当前行:1000
09:46:01.647,当前行:2000
09:46:02.506,当前行:3000
09:46:03.691,当前行:4000
09:46:05.174,当前行:5000 时差 5秒内
09:46:06.969,当前行:6000
09:46:09.326,当前行:7000
09:46:12.556,当前行:8000
09:46:17.643,当前行:9000
09:46:25.334,当前行:10000 时差20秒;
09:46:33.416,当前行:11000
09:46:42.668,当前行:12000
09:46:53.480,当前行:13000
09:47:07.068,当前行:14000
09:47:21.796,当前行:15000,耗时接近60秒
09:47:37.288,当前行:16000
09:47:54.542,当前行:17000
09:48:13.341,当前行:18000
09:48:34.387,当前行:19000
09:48:58.630,当前行:20000 时差接近90秒
09:49:27.398,当前行:21000
09:49:57.990,当前行:22000
09:50:28.021,当前行:23000
09:51:00.486,当前行:24000
09:51:34.667,当前行:25000 时差 90秒
09:52:09.690,当前行:26000
09:52:44.884,当前行:27000
09:53:20.641,当前行:28000
09:53:59.985,当前行:29000
09:53:59.985,当前行:29000
09:54:41.963,当前行:30000 时差 180多秒,
09:55:25.776,当前行:31000
09:56:08.334,当前行:32000
09:57:02.900,当前行:33000
09:57:58.525,当前行:34000
09:58:56.699,当前行:35000 时差250秒,4分多’
效率承递减递减,逐级递减,
当一个2007+ excel存在多个sheet,且只有第一个有具体数据,其他都为空时,读取不到数据。
首先感谢作者开源此工具。用起来确实很方便
模板中这样写没问题
@ExcelProperty(value = {"协议支付","本期新增客户数量"},index = 1)
private String p2;
@ExcelProperty(value = {"协议支付","本期减少客户数量"},index = 2)
private int p3;
@ExcelProperty(value = {"协议支付","本期净增客户数量"},index = 3)
private long p4;
@ExcelProperty(value = {"协议支付","累计签约客户数量"},index = 4)
private String p5;
@ExcelProperty(value = {"商业委托支付","上期末存量客户数量1"},index = 5)
private String p6;
@ExcelProperty(value = {"商业委托支付","本期新增客户数量1"},index = 6)
private String p7;
@ExcelProperty(value = {"商业委托支付","本期减少客户数量1"},index = 7)
private String p8;
@ExcelProperty(value = {"商业委托支付","本期净增客户数量1"},index = 8)
private String p9;
@ExcelProperty(value = {"商业委托支付","累计签约客户数量1"},index = 9)
private String p10;
但是这样写就报错
@ExcelProperty(value = {"协议支付","本期新增客户数量"},index = 1)
private String p2;
@ExcelProperty(value = {"协议支付","本期减少客户数量"},index = 2)
private int p3;
@ExcelProperty(value = {"协议支付","本期净增客户数量"},index = 3)
private long p4;
@ExcelProperty(value = {"协议支付","累计签约客户数量"},index = 4)
private String p5;
@ExcelProperty(value = {"商业委托支付","上期末存量客户数量"},index = 5)
private String p6;
@ExcelProperty(value = {"商业委托支付","本期新增客户数量"},index = 6)
private String p7;
@ExcelProperty(value = {"商业委托支付","本期减少客户数量"},index = 7)
private String p8;
@ExcelProperty(value = {"商业委托支付","本期净增客户数量"},index = 8)
private String p9;
@ExcelProperty(value = {"商业委托支付","累计签约客户数量"},index = 9)
private String p10;
错误信息:
java.lang.IllegalStateException: Cannot add merged region B2:G2 to sheet because it overlaps with an existing merged region (A2:F2).
at org.apache.poi.xssf.usermodel.XSSFSheet.validateMergedRegions(XSSFSheet.java:432)
at org.apache.poi.xssf.usermodel.XSSFSheet.addMergedRegion(XSSFSheet.java:369)
at org.apache.poi.xssf.usermodel.XSSFSheet.addMergedRegion(XSSFSheet.java:323)
at org.apache.poi.xssf.streaming.SXSSFSheet.addMergedRegion(SXSSFSheet.java:390)
at com.alibaba.excel.write.context.GenerateContextImpl.appendHeadToExcel(GenerateContextImpl.java:122)
at com.alibaba.excel.write.context.GenerateContextImpl.buildCurrentSheet(GenerateContextImpl.java:101)
at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:52)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:52)
at function.write.ExcelWriteIndexTest.testDaTong(ExcelWriteIndexTest.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
日志原生日志太少、
Debug日志没有,INFO没有,ERROR没有;
请问是否考虑 增加各类型日志输出
怎么合并单元格呢?
请问支持到处图片到excel吗?如果支持是用什么方式
rt
@ExcelProperty(value = {"表头6","表头61","表头"},index = 0)
private String p7;
@ExcelProperty(value = {"表头6","表头62","表头"},index = 1)
private String p8;
@ExcelProperty(value = {"表头6","表头62","表头"},index = 2)
private String p9;
3级的如果都是表头,直接报错
用easyexcel导出的excel,再导入时报错:java.io.FileNotFoundException: D:\apache-tomcat-8.0.36\temp\easyexcel-4014190947417093486\xl\worksheets\sheet3.xml (系统找不到指定的文件。)
明明应该是sheet1的,这里的workbook.xml里面的sheet中的r:id会变成rId3
读取excel 文件的时候无法将字符串转换为枚举类型
按照模型读取,都是从第一行开始读取,而不是按照Sheet传入参数进行读取,导致模型转换失败。
java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Font.setBold(Z)V
at com.alibaba.excel.write.context.GenerateContextImpl.buildDefaultCellStyle(GenerateContextImpl.java:77)
如何修改读取到文件指定行的内容呢?请赐教
我要修改我读到的文件C22单元格的内容 该如何修改呢
能否提供一个返回每列数据类型的方法呢,用于根据导入excel 数据生成表结构
我用的是mac系统,把官方的例子拷贝过来执行,报下面的错误,莫名其妙,我也不知道错误中那个文件为什么找不到,这个文件不是我的,应该是执行过程中生成的文件。
java.io.FileNotFoundException: /var/folders/p4/ytdlw57579d6tf7fndxzj84r0000gn/T/easyexcel/-4992373293564731499/xl/sharedStrings.xml (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:93) at com.alibaba.excel.read.SaxAnalyserV07.initSharedStringsTable(SaxAnalyserV07.java:221) at com.alibaba.excel.read.SaxAnalyserV07.start(SaxAnalyserV07.java:158) at com.alibaba.excel.read.SaxAnalyserV07.<init>(SaxAnalyserV07.java:61) at com.alibaba.excel.read.ExcelAnalyserImpl.getSaxAnalyser(ExcelAnalyserImpl.java:28) at com.alibaba.excel.read.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:49) at com.alibaba.excel.ExcelReader.read(ExcelReader.java:55)
你好,我想请问下,支持超链接吗?如果支持 我应该怎么加入
读取一个有 10W+ 数据的 Excel 文件,前 5000 条很快,之后速度逐渐变慢,读到几万条的时候速度已经非常非常慢,没办法处理数据量大的文件
采用 @ExcelProperty(value = {"一级表头","二级表头"})用于解决不确切知道excel第几列和该字段映射,位置不固定,但表头的内容知道的情况。
项目里面 是 查询数据库 获取到数据后,写入\生成excel
使用poi的sax读取10W条数据秒级读完,使用easyexcel需要半小时,超级慢
下面代码的是要把list的倒叙排???如果不是要倒叙排是不是直接用链表就可以了。。。。
`
private class SheetSource implements Comparable {
private int id;
private String sheetName;
private InputStream inputStream;
public SheetSource(int id, String sheetName, InputStream inputStream) {
this.id = id;
this.sheetName = sheetName;
this.inputStream = inputStream;
}
public String getSheetName() {
return sheetName;
}
public void setSheetName(String sheetName) {
this.sheetName = sheetName;
}
public InputStream getInputStream() {
return inputStream;
}
public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int compareTo(SheetSource o) {
if (o.id == this.id) {
return 0;
} else if (o.id > this.id) {
return 1;
} else {
return -1;
}
}
}
`
SaxAnalyserV07.java 行,代码行170左右;
if (qName.toLowerCase(Locale.US).equals("sheet")) {
String name = null;
int id = 0;
for (int i = 0; i < attrs.getLength(); i++) {
if (attrs.getLocalName(i).toLowerCase(Locale.US).equals("name")) {// 此处LocalName.执行失效、getQName 生效;
name = attrs.getValue(i);
} else if (attrs.getLocalName(i).toLowerCase(Locale.US).equals("r:id")) {
id = Integer.parseInt(attrs.getValue(i).replaceAll("rId", ""));
try {
InputStream inputStream = new FileInputStream(XMLTempFile.getSheetFilePath(path, id));
sheetSourceList.add(new SheetSource(id, name, inputStream));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
ExcelReader调用finish时,删除临时文件成功,临时目录也应该需要删除吧,
具体代码如下
com.alibaba.excel.util.FileUtil
`
public static void deletefile(String delpath) {
File file = new File(delpath);
if (!file.isDirectory()) {
file.delete();
} else if (file.isDirectory()) {
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
File delfile = new File(delpath + File.separator + filelist[i]);
if (!delfile.isDirectory()) {
delfile.delete();
} else if (delfile.isDirectory()) {
deletefile(delpath + File.separator + filelist[i]);
}
}
// 这里是否需要加一个
file.delete
}
}
`
如题,
导出excel文件 怎么设置单元格属性为数字?
.xlsx文件的字符串数据都存储在sharedStrings.xml中,sheetxxx.xml存储的都是索引,看源码都是将sharedStrings.xml中的所有数据都存储在内存中,如果字符串数据量很大的时候,是不是也会出现oom?
使用easyexcel 导出几十万w量级的数据 ,多批次写达到一定量级会自动刷入么? 像 SXSSF实现了一套自动刷入数据的机制 有么。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.