0
private RowMapper<Person> excelRowMapper() {
        BeanWrapperRowMapper<Person> rowMapper = new BeanWrapperRowMapper<>();
        rowMapper.setTargetType(Person.class);
        return rowMapper;
    }

上面的代码,将第一行视为标题并将第一行 columnNames 与 Person propertyNames 匹配,但我有一个用例,我需要将第二行 columnNames 与 Person propertyNames 匹配,请帮助我如何做到这一点。

我的读者如下

@Bean
    ItemReader<Person> excelStudentReader() {
        PoiItemReader<Person> reader = new PoiItemReader<>();
        reader.setLinesToSkip(2);
        reader.setResource(new ClassPathResource("sample-excel4.xlsx"));
        reader.setRowMapper(excelRowMapper());
        return reader;
    }
4

0 回答 0