Comments (1)
Compared with normal excel import, sax import build titleMap was short of excelParams.
sax is:
private void addHeadData(List<SaxReadCellEntity> datas) {
for (int i = 0; i < datas.size(); i++) {
if (StringUtils.isNotEmpty(String.valueOf(datas.get(i).getValue()))) {
titlemap.put(i, String.valueOf(datas.get(i).getValue()));
}
}
}
normal is:
/**
* 获取表格字段列名对应信息
*/
private Map<Integer, String> getTitleMap(Iterator<Row> rows, ImportParams params,
List<ExcelCollectionParams> excelCollection,
Map<String, ExcelImportEntity> excelParams) {
Map<Integer, String> titlemap = new LinkedHashMap<Integer, String>();
Iterator<Cell> cellTitle;
String collectionName = null;
ExcelCollectionParams collectionParams = null;
Row row = null;
for (int j = 0; j < params.getHeadRows(); j++) {
row = rows.next();
if (row == null) {
continue;
}
cellTitle = row.cellIterator();
while (cellTitle.hasNext()) {
Cell cell = cellTitle.next();
String value = getKeyValue(cell);
value = value.replace("\n", "");
int i = cell.getColumnIndex();
//用以支持重名导入
if (StringUtils.isNotEmpty(value)) {
if (titlemap.containsKey(i)) {
collectionName = titlemap.get(i);
collectionParams = getCollectionParams(excelCollection, collectionName);
titlemap.put(i, collectionName + "_" + value);
} else if (StringUtils.isNotEmpty(collectionName) && collectionParams != null
&& collectionParams.getExcelParams()
.containsKey(collectionName + "_" + value)) {
titlemap.put(i, collectionName + "_" + value);
} else {
collectionName = null;
collectionParams = null;
}
if (StringUtils.isEmpty(collectionName)) {
titlemap.put(i, value);
}
}
}
}
// 处理指定列的情况
Set<String> keys = excelParams.keySet();
for (String key : keys) {
if (key.startsWith("FIXED_")) {
String[] arr = key.split("_");
titlemap.put(Integer.parseInt(arr[1]), key);
}
}
return titlemap;
}
from easypoi.
Related Issues (20)
- ExcelExportEntity 排序bug
- csv 文件导出没有那种¥或者%格式
- 大数据量导出ExcelBatchExportService 不支持 插入下拉列表
- 4.4.0版本excel导出图片失败,excel里没有图片显示,4.3.0版本可以正常导出图片 HOT 1
- 丢失数据&导出数据速度很慢
- cn.afterturn.easypoi.excel.imports.CellValueService#getValue 方法优化
- 复杂表头时列名映射错误
- easypoi-spring-boot-starter 导出图片,4.4.0无,4.2.0有
- 模板导出,个别合并单元格不合并
- excle导入数值,String接收精度丢失问题 HOT 1
- 老哥 ExcelImportService.importExcelByIs 这个地方有一个needMore的参数为true的时候异常的慢
- poi 3.0.3 使用 ExcelExportUtil.exportExcel 报错
- 老哥,替换占位符内容为ImageEntity类型的List时,不能使用 HOT 1
- replace使用
- 导出空集合,需要设置超过10的宽度,不然会报空指针
- sax导入不支持map集合吗 HOT 2
- 遇到变量名如iName这样第二个大写的,在导入excel的时候会报错
- excel表头字段如果是带下划线的比如 : (达标文案_en) , 然后excel就解析不了这个表头所对应的值 HOT 1
- PoiValidationUtil 自定义校验返回message字段名重复问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easypoi.