提交 577fa304 authored 作者: taojinlong's avatar taojinlong

fix: 识别 excel 类型

上级 0ab579b4
......@@ -68,6 +68,6 @@ public class ExcelReaderUtil {
}
public static void main(String[] args) throws Exception {
ExcelReaderUtil.readExcel("111.xls", new FileInputStream("/Users/taojinlong/Desktop/111.xls"));
ExcelReaderUtil.readExcel("跑步数据汇总——万马奔腾版0729.xlsx", new FileInputStream("/Users/taojinlong/Desktop/跑步数据汇总——万马奔腾版0729.xlsx"));
}
}
......@@ -327,7 +327,7 @@ public class ExcelXlsxReader extends DefaultHandler {
formatString = style.getDataFormatString();
short format = this.formatIndex;
if (format == 14 || format == 31 || format == 57 ||format == 59||
format == 58 || (176 <= format && format <= 178)
format == 58 || (176 < format && format < 178)
|| (182 <= format && format <= 196) ||
(210 <= format && format <= 213) || (208 == format))
{ // 日期
......@@ -380,7 +380,7 @@ public class ExcelXlsxReader extends DefaultHandler {
break;
case NUMBER: //数字
if (formatString != null) {
if (formatString != null && isDateFormat) {
thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString).trim();
} else {
thisStr = value;
......@@ -404,7 +404,7 @@ public class ExcelXlsxReader extends DefaultHandler {
}
if(curRow==1){
TableFiled tableFiled = new TableFiled();
tableFiled.setFieldType(type);
tableFiled.setFieldType("TEXT");
tableFiled.setFieldSize(65533);
tableFiled.setFieldName(thisStr);
tableFiled.setRemarks(thisStr);
......@@ -413,8 +413,16 @@ public class ExcelXlsxReader extends DefaultHandler {
if(CollectionUtils.isEmpty(this.getFields())){
throw new RuntimeException(Translator.get("i18n_excel_header_empty"));
}
if(type.equalsIgnoreCase("LONG") && this.getFields().get(curCol).getFieldType().equalsIgnoreCase("TEXT")){
this.getFields().get(curCol).setFieldType(type);
}
if(type.equalsIgnoreCase("DOUBLE") && !this.getFields().get(curCol).getFieldType().equalsIgnoreCase("DATETIME")){
this.getFields().get(curCol).setFieldType(type);
}
if(type.equalsIgnoreCase("DATETIME")){
this.getFields().get(curCol).setFieldType(type);
}
}
return thisStr;
}
......@@ -428,9 +436,7 @@ public class ExcelXlsxReader extends DefaultHandler {
thisStr = String.valueOf(Double.valueOf(thisStr)/100);
}
Long.valueOf(thisStr);
if(this.getFields().get(curCol).getFieldType().equalsIgnoreCase("TEXT")){
return "LONG";
}
}catch (Exception e){
try {
Double.valueOf(thisStr);
......
......@@ -236,6 +236,7 @@ export default {
this.tableData = []
if (this.currGroup) {
this.dsLoading = true
this.tables = [];
post('/dataset/table/list', {
sort: 'type asc,name asc,create_time desc',
sceneId: this.currGroup.id,
......@@ -351,6 +352,7 @@ export default {
if (!this.isTreeSearch) {
if (node.data.id) {
this.dsLoading = true
this.tables = [];
post('/dataset/table/listAndGroup', {
sort: 'type asc,name asc,create_time desc',
sceneId: node.data.id,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论