sargeraswang / excelutil Goto Github PK
View Code? Open in Web Editor NEW用于导入导出Excel的Util包,基于Java的POI。可将List<Bean>导出成Excel,或读取Excel成List<Bean>,读取时有验证和Log。
用于导入导出Excel的Util包,基于Java的POI。可将List<Bean>导出成Excel,或读取Excel成List<Bean>,读取时有验证和Log。
不支持指定sheet页啊,一个Excel中多个sheet时不能指定sheet页
大佬,我在使用excel-util时,遇到一个需要设置cellType的需要,能否在excel-util中增加此功能呢?
如题, 我有多个DataSet需要导入,对应的导入到多个Sheet
我在使用时发现excel解析出来的bean中的字段都为Null?
导出excel的取值方法, 可以提取出来。
感谢楼主的分享,不过在使用过程中设置的列宽自适应仍然不会生效,部分方法已过时,作者如果有时间要是能升级这2块就完美了!
既然已经使用了 LinkedHashMap 按顺序指定了属性名和对应的列名,完全可以直接使用属性名来按顺序取Model对象对应值就可以了,不使用 @ExcelCell(index = ?) 注解来指定列的位置也可以进行导出,导出列很多的情况下标注每个的对象的位置很麻烦。
主要是在导出时,添加注解对导出对象有一定的侵入性,不想新建一个专门用来导出数据的对象并进行数据拷贝。
some examples will be helpful.
使用bean的话,只能使用Double类型来定义和接受数值
**库只有1.2.1版本的
Execution failed for task ':app:checkDebugDuplicateClasses'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class org.apache.commons.collections.ArrayStack found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.Buffer found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.BufferUnderflowException found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.FastHashMap found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.FastHashMap$1 found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.FastHashMap$CollectionView found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.FastHashMap$CollectionView$CollectionViewIterator found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.FastHashMap$EntrySet found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.FastHashMap$KeySet found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.commons.collections.FastHashMap$Values found in modules commons-beanutils-1.8.3 (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1 (commons-collections:commons-collections:3.2.1)
Duplicate class org.apache.xmlbeans.xml.stream.Location found in modules xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.ReferenceResolver found in modules xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.XMLEvent found in modules xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.XMLInputStream found in modules xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.XMLName found in modules xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.XMLStreamException found in modules xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.utils.NestedThrowable found in modules xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.utils.NestedThrowable$Util found in modules xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0 (org.apache.xmlbeans:xmlbeans:2.6.0)
添加笔主给的Maven依赖pom.xml项目上会有感叹号错误(猜测是jar包导入错误)
docker 镜像 FROM java:8-jre-alpine
那块代码希望作者完善一下,还有文档希望可以增加示例
org.gradle.execution.MultipleBuildFailures: Build completed with 1 failures
——————————————————————————————————————————
duplicate class org.apache.commons.collections.arraystack found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.2.1.jar (commons-collections:commons-collections:3.2.1
——————————————————————————————————————————
Duplicate class org.apache.commons.collections.ArrayStack found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.Buffer found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.BufferUnderflowException found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.FastHashMap found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.FastHashMap$1 found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.FastHashMap$CollectionView found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.FastHashMap$CollectionView$CollectionViewIterator found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.FastHashMap$EntrySet found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.FastHashMap$KeySet found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.commons.collections.FastHashMap$Values found in modules commons-beanutils-1.8.3.jar (commons-beanutils:commons-beanutils:1.8.3) and commons-collections-3.1.jar (apache-collections:commons-collections:3.1)
Duplicate class org.apache.xmlbeans.xml.stream.Location found in modules xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.ReferenceResolver found in modules xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.XMLEvent found in modules xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.XMLInputStream found in modules xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.XMLName found in modules xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.XMLStreamException found in modules xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.utils.NestedThrowable found in modules xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0)
Duplicate class org.apache.xmlbeans.xml.stream.utils.NestedThrowable$Util found in modules xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0) and xmlbeans-2.6.0.jar (org.apache.xmlbeans:xmlbeans:2.6.0)
当要导出四五十个字段的时候,设置表头的工作量很大,代码也难看
// 如果類型不在指定範圍內,並且沒有默認值
if (!(cellTypes.contains(cell.getCellTypeEnum()))
|| isNotBlank(annoCell.defaultValue())
&& cell.getCellTypeEnum() == CellType.STRING) {
StringBuilder strType = new StringBuilder();
for (int i = 0; i < cellTypes.size(); i++) {
CellType cellType = cellTypes.get(i);
strType.append(getCellTypeByInt(cellType));
if (i != cellTypes.size() - 1) {
strType.append(",");
}
}
result =
MessageFormat.format("the cell [{0}] type must [{1}]", columnName, strType.toString());
}
这个地方没看懂, 没有默认值,不应该是 isBlank(annoCell.defaultValue()) 吗? 是不是应该改为
// 如果類型不在指定範圍內,並且沒有默認值
if (!(cellTypes.contains(cell.getCellTypeEnum()))
&& isBlank(annoCell.defaultValue())) {
StringBuilder strType = new StringBuilder();
for (int i = 0; i < cellTypes.size(); i++) {
CellType cellType = cellTypes.get(i);
strType.append(getCellTypeByInt(cellType));
if (i != cellTypes.size() - 1) {
strType.append(",");
}
}
result =
MessageFormat.format("the cell [{0}] type must [{1}]", columnName, strType.toString());
}
我根据方法要求吧传入的日期按照日期格式输入好(如yyyy/MM/dd) 但是输出的内容并不是Date类型(内容为:43039.3816203704)
错误: Cannot get a STRING value from a NUMERIC cell.
修改如下,希望作者加入master
ExcelUtil.java(448行)
for (String k : titleMap.keySet()) {
Integer index = titleMap.get(k);
Cell cell = row.getCell(index);
// 判空
if (cell == null) {
map.put(k, null);
} else {
cell.setCellType(CellType.STRING);
String value = cell.getStringCellValue();
map.put(k, value);
}
}
可以在excel裡面追加数据么?
@ExcelCell.Valid(allowNull = false),在bean上的属性上设置改注解无效
如题,遇到一个这种需求
如何单独给表头和非表头设置独立的样式,比如我要给表头设置文字加粗,非标头默认样式显示,不加粗,刚开始使用cell.setCellStyle(style);会报错,后来在网上查了要这样写“cell.getCellStyle().cloneStyleFrom(style);”,倒是可以加粗,但是所有单元格都加粗了
是不是漏了validateMap.put(Date.class, new Integer[]{Cell.CELL_TYPE_NUMERIC, Cell.CELL_TYPE_STRING, Cell.CELL_TYPE_FORMULA});
为了方便快捷, 希望作者把构件上传至**库, 一劳永逸.
发布流程可以参考: http://www.arccode.net/publish-artifact-to-maven-central-repository.html
导出为map时,标题全乱了,建议改为LinkedHashMap
导入那块代码希望作者完善一下
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.