forked from github/dataease
fix: 识别 excel 类型
This commit is contained in:
parent
0ab579b4fe
commit
577fa304f0
@ -68,6 +68,6 @@ public class ExcelReaderUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
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();
|
formatString = style.getDataFormatString();
|
||||||
short format = this.formatIndex;
|
short format = this.formatIndex;
|
||||||
if (format == 14 || format == 31 || format == 57 ||format == 59||
|
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) ||
|
|| (182 <= format && format <= 196) ||
|
||||||
(210 <= format && format <= 213) || (208 == format))
|
(210 <= format && format <= 213) || (208 == format))
|
||||||
{ // 日期
|
{ // 日期
|
||||||
@ -380,7 +380,7 @@ public class ExcelXlsxReader extends DefaultHandler {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case NUMBER: //数字
|
case NUMBER: //数字
|
||||||
if (formatString != null) {
|
if (formatString != null && isDateFormat) {
|
||||||
thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString).trim();
|
thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString).trim();
|
||||||
} else {
|
} else {
|
||||||
thisStr = value;
|
thisStr = value;
|
||||||
@ -404,7 +404,7 @@ public class ExcelXlsxReader extends DefaultHandler {
|
|||||||
}
|
}
|
||||||
if(curRow==1){
|
if(curRow==1){
|
||||||
TableFiled tableFiled = new TableFiled();
|
TableFiled tableFiled = new TableFiled();
|
||||||
tableFiled.setFieldType(type);
|
tableFiled.setFieldType("TEXT");
|
||||||
tableFiled.setFieldSize(65533);
|
tableFiled.setFieldSize(65533);
|
||||||
tableFiled.setFieldName(thisStr);
|
tableFiled.setFieldName(thisStr);
|
||||||
tableFiled.setRemarks(thisStr);
|
tableFiled.setRemarks(thisStr);
|
||||||
@ -413,7 +413,15 @@ public class ExcelXlsxReader extends DefaultHandler {
|
|||||||
if(CollectionUtils.isEmpty(this.getFields())){
|
if(CollectionUtils.isEmpty(this.getFields())){
|
||||||
throw new RuntimeException(Translator.get("i18n_excel_header_empty"));
|
throw new RuntimeException(Translator.get("i18n_excel_header_empty"));
|
||||||
}
|
}
|
||||||
this.getFields().get(curCol).setFieldType(type);
|
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;
|
return thisStr;
|
||||||
}
|
}
|
||||||
@ -428,9 +436,7 @@ public class ExcelXlsxReader extends DefaultHandler {
|
|||||||
thisStr = String.valueOf(Double.valueOf(thisStr)/100);
|
thisStr = String.valueOf(Double.valueOf(thisStr)/100);
|
||||||
}
|
}
|
||||||
Long.valueOf(thisStr);
|
Long.valueOf(thisStr);
|
||||||
if(this.getFields().get(curCol).getFieldType().equalsIgnoreCase("TEXT")){
|
return "LONG";
|
||||||
return "LONG";
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
try {
|
try {
|
||||||
Double.valueOf(thisStr);
|
Double.valueOf(thisStr);
|
||||||
|
@ -236,6 +236,7 @@ export default {
|
|||||||
this.tableData = []
|
this.tableData = []
|
||||||
if (this.currGroup) {
|
if (this.currGroup) {
|
||||||
this.dsLoading = true
|
this.dsLoading = true
|
||||||
|
this.tables = [];
|
||||||
post('/dataset/table/list', {
|
post('/dataset/table/list', {
|
||||||
sort: 'type asc,name asc,create_time desc',
|
sort: 'type asc,name asc,create_time desc',
|
||||||
sceneId: this.currGroup.id,
|
sceneId: this.currGroup.id,
|
||||||
@ -351,6 +352,7 @@ export default {
|
|||||||
if (!this.isTreeSearch) {
|
if (!this.isTreeSearch) {
|
||||||
if (node.data.id) {
|
if (node.data.id) {
|
||||||
this.dsLoading = true
|
this.dsLoading = true
|
||||||
|
this.tables = [];
|
||||||
post('/dataset/table/listAndGroup', {
|
post('/dataset/table/listAndGroup', {
|
||||||
sort: 'type asc,name asc,create_time desc',
|
sort: 'type asc,name asc,create_time desc',
|
||||||
sceneId: node.data.id,
|
sceneId: node.data.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user