Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解析合并表头Excel丢失合并头字段信息 #306

Open
CarlJia opened this issue Nov 4, 2022 · 0 comments
Open

解析合并表头Excel丢失合并头字段信息 #306

CarlJia opened this issue Nov 4, 2022 · 0 comments
Labels

Comments

@CarlJia
Copy link
Contributor

CarlJia commented Nov 4, 2022

eec版本:0.5.4

样例代码

    @Test
    public void testRead() throws IOException {
        try (ExcelReader reader = ExcelReader.read(testResourceRoot().resolve("设备-检查项目导入模板.xlsx"), 4)) {
            Sheet sheet = reader.sheet(0).bind(DeviceCheckExport.class).asMergeSheet();

            Iterator<Row> rowIterator = sheet.dataIterator();
            while (rowIterator.hasNext()) {
                Row row = rowIterator.next();
                // 行数据转对象
                DeviceCheckExport importEntity = row.to(DeviceCheckExport.class);
                System.out.println(importEntity);
            }
        }
    }
public static class DeviceCheckExport {

        @ExcelColumn(value = "设备装置编码", maxWidth = 30.00D)
        @HeaderStyle(fontColor = "red", fillFgColor = "white")
        private String deviceCode;
        private Long deviceId;

        @ExcelColumn(value = "管控措施分类")
        @ExcelColumn(value = "管控措施一级分类", maxWidth = 30.00D)
        private String measureTypeFirName;
        private Long measureTypeFir;

        @ExcelColumn(value = "管控措施分类")
        @ExcelColumn(value = "管控措施二级分类", maxWidth = 30.00D)
        private String measureTypeSenName;
        private Long measureTypeSen;

        @ExcelColumn(value = "管控措施分类")
        @ExcelColumn(value = "管控措施三级分类", maxWidth = 30.00D)
        private String measureTypeThrName;
        private Long measureTypeThr;

        @ExcelColumn(value = "检查项目", maxWidth = 30.00D)
        @HeaderStyle(fontColor = "red", fillFgColor = "white")
        private String content;

        @ExcelColumn(value = "检查标准", maxWidth = 30.00D)
        @HeaderStyle(fontColor = "red", fillFgColor = "white")
        private String standard;

        @ExcelColumn(value = "记录数据类型", maxWidth = 30.00D)
        @HeaderStyle(fontColor = "red", fillFgColor = "white")
        private String dataTypeName;
        private Long dataTypeId;

        @ExcelColumn(value = "数值计算逻辑", maxWidth = 30.00D)
        private String symbol;

        @ExcelColumn(value = "正常值", maxWidth = 30.00D)
        @HeaderStyle(fontColor = "red", fillFgColor = "white")
        private String normalValue;
        private Long normalDataOptionId;
        private String normalLeft;
        private String normalRight;

        public String getDeviceCode() {
            return deviceCode;
        }

        public void setDeviceCode(String deviceCode) {
            this.deviceCode = deviceCode;
        }

        public Long getDeviceId() {
            return deviceId;
        }

        public void setDeviceId(Long deviceId) {
            this.deviceId = deviceId;
        }

        public String getMeasureTypeFirName() {
            return measureTypeFirName;
        }

        public void setMeasureTypeFirName(String measureTypeFirName) {
            this.measureTypeFirName = measureTypeFirName;
        }

        public Long getMeasureTypeFir() {
            return measureTypeFir;
        }

        public void setMeasureTypeFir(Long measureTypeFir) {
            this.measureTypeFir = measureTypeFir;
        }

        public String getMeasureTypeSenName() {
            return measureTypeSenName;
        }

        public void setMeasureTypeSenName(String measureTypeSenName) {
            this.measureTypeSenName = measureTypeSenName;
        }

        public Long getMeasureTypeSen() {
            return measureTypeSen;
        }

        public void setMeasureTypeSen(Long measureTypeSen) {
            this.measureTypeSen = measureTypeSen;
        }

        public String getMeasureTypeThrName() {
            return measureTypeThrName;
        }

        public void setMeasureTypeThrName(String measureTypeThrName) {
            this.measureTypeThrName = measureTypeThrName;
        }

        public Long getMeasureTypeThr() {
            return measureTypeThr;
        }

        public void setMeasureTypeThr(Long measureTypeThr) {
            this.measureTypeThr = measureTypeThr;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getStandard() {
            return standard;
        }

        public void setStandard(String standard) {
            this.standard = standard;
        }

        public String getDataTypeName() {
            return dataTypeName;
        }

        public void setDataTypeName(String dataTypeName) {
            this.dataTypeName = dataTypeName;
        }

        public Long getDataTypeId() {
            return dataTypeId;
        }

        public void setDataTypeId(Long dataTypeId) {
            this.dataTypeId = dataTypeId;
        }

        public String getSymbol() {
            return symbol;
        }

        public void setSymbol(String symbol) {
            this.symbol = symbol;
        }

        public String getNormalValue() {
            return normalValue;
        }

        public void setNormalValue(String normalValue) {
            this.normalValue = normalValue;
        }

        public Long getNormalDataOptionId() {
            return normalDataOptionId;
        }

        public void setNormalDataOptionId(Long normalDataOptionId) {
            this.normalDataOptionId = normalDataOptionId;
        }

        public String getNormalLeft() {
            return normalLeft;
        }

        public void setNormalLeft(String normalLeft) {
            this.normalLeft = normalLeft;
        }

        public String getNormalRight() {
            return normalRight;
        }

        public void setNormalRight(String normalRight) {
            this.normalRight = normalRight;
        }

        @Override
        public String toString() {
            return "DeviceCheckExport{" +
                    "deviceCode='" + deviceCode + '\'' +
                    ", deviceId=" + deviceId +
                    ", measureTypeFirName='" + measureTypeFirName + '\'' +
                    ", measureTypeFir=" + measureTypeFir +
                    ", measureTypeSenName='" + measureTypeSenName + '\'' +
                    ", measureTypeSen=" + measureTypeSen +
                    ", measureTypeThrName='" + measureTypeThrName + '\'' +
                    ", measureTypeThr=" + measureTypeThr +
                    ", content='" + content + '\'' +
                    ", standard='" + standard + '\'' +
                    ", dataTypeName='" + dataTypeName + '\'' +
                    ", dataTypeId=" + dataTypeId +
                    ", symbol='" + symbol + '\'' +
                    ", normalValue='" + normalValue + '\'' +
                    ", normalDataOptionId=" + normalDataOptionId +
                    ", normalLeft='" + normalLeft + '\'' +
                    ", normalRight='" + normalRight + '\'' +
                    '}';
        }
    }

实际结果
image

image

期望
1.支持手动指定表头行解析
2.bind合并表头对象能自动解析最大深度表头映射到对象真实字段

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants