parent
a72958e8cf
commit
6a1bbf2fa4
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
package com.dsideal.base.Tools.Excel.Bean;
|
||||
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.dsideal.base.Tools.Excel.Util.ExcelUtil;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class School2019 {
|
||||
@ExcelProperty(index = 1) // B列
|
||||
private String schoolName;
|
||||
|
||||
@ExcelProperty(index = 3) // D列
|
||||
private String schoolType;
|
||||
|
||||
@ExcelProperty(index = 5) // F列
|
||||
private Integer schoolCount;
|
||||
|
||||
@ExcelProperty(index = 350) // MM列
|
||||
private String city;
|
||||
|
||||
@ExcelProperty(index = 351) // MN列
|
||||
private String district;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 测试字母标号转列索引
|
||||
String columnLetter = "MM"; // 示例输入
|
||||
int columnIndex = ExcelUtil.columnLetterToIndex(columnLetter);
|
||||
System.out.printf("字母标号 %s 对应的列索引是: %d%n", columnLetter, columnIndex);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.dsideal.base.Tools.Excel;
|
||||
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SchoolData {
|
||||
@ExcelProperty(index = 1) // B列
|
||||
private String schoolName;
|
||||
|
||||
@ExcelProperty(index = 3) // D列
|
||||
private String schoolType;
|
||||
|
||||
@ExcelProperty(index = 5) // F列
|
||||
private Integer schoolCount;
|
||||
|
||||
@ExcelProperty(index = 350) // MM列
|
||||
private String city;
|
||||
|
||||
@ExcelProperty(index = 351) // MN列
|
||||
private String district;
|
||||
}
|
@ -1,24 +1,9 @@
|
||||
package com.dsideal.base.Tools.Excel;
|
||||
package com.dsideal.base.Tools.Excel.Util;
|
||||
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ExcelUtil {
|
||||
public static void main(String[] args) {
|
||||
// 设置 com.alibaba.excel 的日志级别为 INFO
|
||||
Logger excelLogger = (Logger) LoggerFactory.getLogger("com.alibaba.excel");
|
||||
excelLogger.setLevel(Level.INFO);
|
||||
|
||||
// 测试字母标号转列索引
|
||||
String columnLetter = "MM"; // 示例输入
|
||||
int columnIndex = columnLetterToIndex(columnLetter);
|
||||
System.out.printf("字母标号 %s 对应的列索引是: %d%n", columnLetter, columnIndex);
|
||||
}
|
||||
|
||||
// 将字母标号转换为列索引
|
||||
private static int columnLetterToIndex(String columnLetter) {
|
||||
public static int columnLetterToIndex(String columnLetter) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < columnLetter.length(); i++) {
|
||||
char c = columnLetter.charAt(i);
|
Loading…
Reference in new issue