dev^2
itcast 1 year ago
parent b34b278fb7
commit b4e0df4711
  1. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java
  2. 50
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java

@ -439,7 +439,7 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
}
ExcelInfo excelInfo = new ExcelInfo();
excelInfo.setcells(cells);
excelInfo.setcells(cells,workbook);
Fieldx222 fieldx222 = new Fieldx222();
if (StringUtil.isBlank(excelInfo.getTableId())) {
message.put("isError", "true");

@ -1,8 +1,7 @@
package org.jeecg.modules.fieldx.dto;
import com.aliyuncs.utils.StringUtils;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Table;
import org.apache.poi.ss.usermodel.*;
import org.jeecg.modules.tablex.entity.Tablex;
import org.jeecg.modules.tablex.service.impl.TablexServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@ -17,12 +16,14 @@ import java.util.List;
@Component
public class ExcelInfo {
private Row cells;
private Workbook workbook;
@Autowired
private TablexServiceImpl tablexService;
public void setcells(Row cells){
public void setcells(Row cells ,Workbook workbook){
this.cells = cells;
this.workbook=workbook;
}
public static ExcelInfo excelInfo;
@PostConstruct
@ -31,7 +32,7 @@ public class ExcelInfo {
excelInfo.tablexService=this.tablexService;
}
public String getTableId(){
String value=cells.getCell(1).getStringCellValue();
String value=zhcell(cells.getCell(1));
System.out.println("value = ==================================" + value);
if(StringUtils.isEmpty(value))
return null;
@ -45,77 +46,77 @@ public class ExcelInfo {
}
public String getFieldName(){
String value=cells.getCell(2).getStringCellValue();
String value=zhcell(cells.getCell(2));
return getvalue(value);
}
public String getFieldEnName(){
String value=cells.getCell(3).getStringCellValue();
String value=zhcell(cells.getCell(3));
return getvalue(value);
}
public String getType(){
String value=cells.getCell(4).getStringCellValue();
String value=zhcell(cells.getCell(4));
return getvalue(value);
}
public String getLength(){
String value=cells.getCell(5).getStringCellValue();
String value=zhcell(cells.getCell(5));
return getvalue(value);
}
public String getAccuracy(){
String value=cells.getCell(6).getStringCellValue();
String value=zhcell(cells.getCell(6));
return getvalue(value);
}
public String getFormat(){
String value=cells.getCell(7).getStringCellValue();
String value=zhcell(cells.getCell(7));
return getvalue(value);
}
public String getIsPk(){
String value=cells.getCell(8).getStringCellValue();
String value=zhcell(cells.getCell(8));
return getvalue(value);
}
public String getIsFk(){
String value=cells.getCell(9).getStringCellValue();
String value=zhcell(cells.getCell(9));
return getvalue(value);
}
public String getAssociateTable(){
String value=cells.getCell(10).getStringCellValue();
String value=zhcell(cells.getCell(10));
return getvalue(value);
}
public String getAssociateField(){
String value=cells.getCell(11).getStringCellValue();
String value=zhcell(cells.getCell(11));
return getvalue(value);
}
public String getIsNull(){
String value=cells.getCell(12).getStringCellValue();
String value=zhcell(cells.getCell(12));
return getvalue(value);
}
public String getIsUniqueness(){
String value=cells.getCell(13).getStringCellValue();
String value=zhcell(cells.getCell(13));
return getvalue(value);
}
public String getRule(){
String value=cells.getCell(14).getStringCellValue();
String value=zhcell(cells.getCell(14));
return getvalue(value);
}
public String getStatus(){
String value=cells.getCell(15).getStringCellValue();
String value=zhcell(cells.getCell(15));
return getvalue(value);
}
public String getVerisonStatus(){
String value=cells.getCell(16).getStringCellValue();
String value=zhcell(cells.getCell(16));
return getvalue(value);
}
@ -178,6 +179,17 @@ public class ExcelInfo {
return "26";
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;
}
}

Loading…
Cancel
Save