main
黄海 2 years ago
parent 7012a44134
commit da57e3188f

@ -29,7 +29,6 @@ public class ImportExcelData {
public static String upload_excel_filename = "b61a2af2-223f-4058-a675-b212e4dd9487" + ".xlsx";
public static void main(String[] args) throws IOException {
//加载License
AsposeUtil.getLicense();
@ -76,19 +75,23 @@ public class ImportExcelData {
//数据有效行数
int lastRowNum = sheet.getLastRowNum();
List<Record> list = ImportUtil.getExcelSheetColumnsInfo(upload_excel_filename, i);
//遍历每一列
List<Record> list = ImportUtil.getExcelSheetColumnsInfo(upload_excel_filename, i);
int colIdx = 0;
for (Record record : list) {//列
System.out.println(record);
int excel_column_idx = record.getInt("excel_column_idx");//第几列
String column_type = record.getStr("column_type");//类型
boolean allow_blank = record.getBoolean("allow_blank");//是不是允许为空
System.out.println("Sheet=" + i + ",excel_column_idx=" + excel_column_idx + ",allow_blank=" + allow_blank);
if (!allow_blank) {
System.out.println("现在是第" + i + "个Sheet!");
// 非空项目未填写
for (int j = data_start_row; j <= lastRowNum; j++) {//行
if (StrKit.isBlank(ImportUtil.getCellValue(sheet.getRow(j).getCell(colIdx)).toString())) {
System.out.println("Sheet=" + sheet.getSheetName() + ",Rows=" + j + ",Column=" + colIdx + "不允许为空!");
System.out.println("SheetIdx=" + i + ",Rows=" + j + ",Column=" + colIdx + "不允许为空!");
System.exit(0);
}
}

@ -292,18 +292,21 @@ public class ImportUtil {
//写入模板与表结构的关系t_importexcel_mapping
String sql = "delete from t_importexcel_mapping where table_name=?";
Db.update(sql, tableName);
int sheet_index = input.getInt("sheet_index");
String sheet_name = input.getStr("sheet_name");
List<Record> writeList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
Record record = new Record();
record.set("table_name", tableName);
record.set("column_name", list.get(i).getStr("column_name"));
record.set("excel_column_idx", i + 1);
record.set("excel_column_idx", i);
record.set("memo", list.get(i).getStr("memo"));
record.set("allow_blank", list.get(i).getBoolean("allow_blank"));
record.set("column_type", convertDataType(list.get(i).getStr("column_type")));
record.set("upload_excel_filename", upload_excel_filename);
record.set("sheet_index", i);
record.set("sheet_name", sheetName);
record.set("sheet_index", sheet_index);
record.set("sheet_name", sheet_name);
record.set("options", list.get(i).getStr("options"));
writeList.add(record);
}
@ -317,11 +320,9 @@ public class ImportUtil {
int end_row = input.getInt("end_row");
int start_column = input.getInt("start_column");
int end_column = input.getInt("end_column");
int sheet_index = input.getInt("sheet_index");
int data_start_row = input.getInt("data_start_row");
int column_num = input.getInt("column_num");
String sheet_name = input.getStr("sheet_name");
Record record = new Record();
record.set("upload_excel_filename", upload_excel_filename);
record.set("table_name", tableName);

Loading…
Cancel
Save