|
|
@ -1,8 +1,7 @@ |
|
|
|
package org.jeecg.modules.fieldx.dto; |
|
|
|
package org.jeecg.modules.fieldx.dto; |
|
|
|
|
|
|
|
|
|
|
|
import com.aliyuncs.utils.StringUtils; |
|
|
|
import com.aliyuncs.utils.StringUtils; |
|
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
|
import org.apache.poi.ss.usermodel.Table; |
|
|
|
|
|
|
|
import org.jeecg.modules.tablex.entity.Tablex; |
|
|
|
import org.jeecg.modules.tablex.entity.Tablex; |
|
|
|
import org.jeecg.modules.tablex.service.impl.TablexServiceImpl; |
|
|
|
import org.jeecg.modules.tablex.service.impl.TablexServiceImpl; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -17,12 +16,14 @@ import java.util.List; |
|
|
|
@Component |
|
|
|
@Component |
|
|
|
public class ExcelInfo { |
|
|
|
public class ExcelInfo { |
|
|
|
private Row cells; |
|
|
|
private Row cells; |
|
|
|
|
|
|
|
private Workbook workbook; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private TablexServiceImpl tablexService; |
|
|
|
private TablexServiceImpl tablexService; |
|
|
|
|
|
|
|
|
|
|
|
public void setcells(Row cells){ |
|
|
|
public void setcells(Row cells ,Workbook workbook){ |
|
|
|
this.cells = cells; |
|
|
|
this.cells = cells; |
|
|
|
|
|
|
|
this.workbook=workbook; |
|
|
|
} |
|
|
|
} |
|
|
|
public static ExcelInfo excelInfo; |
|
|
|
public static ExcelInfo excelInfo; |
|
|
|
@PostConstruct |
|
|
|
@PostConstruct |
|
|
@ -31,7 +32,7 @@ public class ExcelInfo { |
|
|
|
excelInfo.tablexService=this.tablexService; |
|
|
|
excelInfo.tablexService=this.tablexService; |
|
|
|
} |
|
|
|
} |
|
|
|
public String getTableId(){ |
|
|
|
public String getTableId(){ |
|
|
|
String value=cells.getCell(1).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(1)); |
|
|
|
System.out.println("value = ==================================" + value); |
|
|
|
System.out.println("value = ==================================" + value); |
|
|
|
if(StringUtils.isEmpty(value)) |
|
|
|
if(StringUtils.isEmpty(value)) |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -45,77 +46,77 @@ public class ExcelInfo { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getFieldName(){ |
|
|
|
public String getFieldName(){ |
|
|
|
String value=cells.getCell(2).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(2)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getFieldEnName(){ |
|
|
|
public String getFieldEnName(){ |
|
|
|
String value=cells.getCell(3).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(3)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getType(){ |
|
|
|
public String getType(){ |
|
|
|
String value=cells.getCell(4).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(4)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getLength(){ |
|
|
|
public String getLength(){ |
|
|
|
String value=cells.getCell(5).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(5)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getAccuracy(){ |
|
|
|
public String getAccuracy(){ |
|
|
|
String value=cells.getCell(6).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(6)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getFormat(){ |
|
|
|
public String getFormat(){ |
|
|
|
String value=cells.getCell(7).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(7)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getIsPk(){ |
|
|
|
public String getIsPk(){ |
|
|
|
String value=cells.getCell(8).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(8)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getIsFk(){ |
|
|
|
public String getIsFk(){ |
|
|
|
String value=cells.getCell(9).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(9)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getAssociateTable(){ |
|
|
|
public String getAssociateTable(){ |
|
|
|
String value=cells.getCell(10).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(10)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getAssociateField(){ |
|
|
|
public String getAssociateField(){ |
|
|
|
String value=cells.getCell(11).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(11)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getIsNull(){ |
|
|
|
public String getIsNull(){ |
|
|
|
String value=cells.getCell(12).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(12)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getIsUniqueness(){ |
|
|
|
public String getIsUniqueness(){ |
|
|
|
String value=cells.getCell(13).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(13)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getRule(){ |
|
|
|
public String getRule(){ |
|
|
|
String value=cells.getCell(14).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(14)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getStatus(){ |
|
|
|
public String getStatus(){ |
|
|
|
String value=cells.getCell(15).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(15)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getVerisonStatus(){ |
|
|
|
public String getVerisonStatus(){ |
|
|
|
String value=cells.getCell(16).getStringCellValue(); |
|
|
|
String value=zhcell(cells.getCell(16)); |
|
|
|
return getvalue(value); |
|
|
|
return getvalue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -178,6 +179,17 @@ public class ExcelInfo { |
|
|
|
return "26"; |
|
|
|
return "26"; |
|
|
|
return value; |
|
|
|
return value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String zhcell(Cell cell){ |
|
|
|
|
|
|
|
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建数据格式化器
|
|
|
|
|
|
|
|
DataFormatter formatter = new DataFormatter(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清除单元格的样式
|
|
|
|
|
|
|
|
cell.setCellStyle(null); |
|
|
|
|
|
|
|
//使用数据格式化器和公式求值器,将单元格的值格式化为字符串
|
|
|
|
|
|
|
|
String name = formatter.formatCellValue(cell, evaluator); |
|
|
|
|
|
|
|
return name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|