Skip to content

[Bug] Unable to set use1904windowing when reading xlsx files #433

@delei

Description

@delei

Search before asking

  • I searched in the issues and found nothing similar.

Fastexcel version

1.2.0

JDK version

OpenJDK 1.80_452

Operating system

No response

Minimal reproduce step

Test case

@Slf4j
public class Issue3745Test {
    @Test
    void testUse1904windowing() throws Exception {
        File testFile = TestFileUtil.createNewFile("issue/easyexcel/test.xlsx");

        // write file
        FastExcel.write(testFile, DemoData.class).excelType(ExcelTypeEnum.XLSX)
                .use1904windowing(Boolean.TRUE)  // set use1904windowing to TRUE
                .sheet()
                .doWrite(demoData(1));

        FastExcel.read(testFile, new AnalysisEventListener<DemoData>() {
                    @Override
                    public void invoke(DemoData data, AnalysisContext context) {
                        boolean isUse1904windowing = context.readSheetHolder().globalConfiguration().getUse1904windowing();
                        log.info("isUse1904windowing: {}", isUse1904windowing);
                        Assertions.assertTrue(isUse1904windowing);
                    }

                    @Override
                    public void doAfterAllAnalysed(AnalysisContext context) {
                    }
                })
                .excelType(ExcelTypeEnum.XLSX)
                .head(DemoData.class)
                .sheet()
                .doReadSync();
    }

    private List<DemoData> demoData(int size) {
        List<DemoData> dataList = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            DemoData demoData = new DemoData();
            demoData.setString("String" + i);
            demoData.setDate(DateUtil.date());
            demoData.setDoubleData(RandomUtil.randomDouble());
            dataList.add(demoData);
        }
        return dataList;
    }
}

What did you expect to see?

For the xlsx files, according to the logic of XlsxSaxAnalyser#analysisUse1904WindowDate method , the value of use1904windowing should be true when reading the file.

What did you see instead?

The value of use1904windowing always be false.

Image

Anything else?

Related Issue

easyexcel-issue-3745

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions