From b90a1321471bcbaf76f3ce3122480d0431598841 Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Tue, 3 Feb 2015 22:30:09 +0100 Subject: [PATCH] polish Added Java Config Added BeanWrapperRowMapper --- spring-batch-excel/README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/spring-batch-excel/README.md b/spring-batch-excel/README.md index 9aa8b60..0f80418 100644 --- a/spring-batch-excel/README.md +++ b/spring-batch-excel/README.md @@ -12,6 +12,8 @@ There are 2 `ItemReaders` one can configure: Configuration of both readers is the same. +#### XML + @@ -19,6 +21,21 @@ Configuration of both readers is the same. +#### Java Config + + @Bean + public PoiItemReader excelReader() { + PoiItemReader reader = new PoiItemReader(); + reader.setResource(new ClassPathResource("/path/to/your/excel/file")); + reader.setRowMapper(rowMapper()); + return reader; + } + + @Bean + public RowMapper rowMapper() { + return new PassThroughRowMapper(); + } + Each reader takes a `resource` and a `rowMapper`. The `resource` is the location of the excel file to read and the `rowMapper` transforms the rows in excel to an object which you can use in the rest of the process. Optionally one can also set the `skippedRowsCallback`, `linesToSkip`, `strict` and `rowSetFactory` properties. @@ -44,13 +61,13 @@ Next to the default `ItemReader` implementations there are also 2 `RowMapper` im ### PassThroughRowMapper Transforms the read row from excel into a `String[]`. -### BeanPropertyRowMapper +### BeanWrapperRowMapper Uses a `BeanWrapper` to convert a given row into an object. Uses the column names of the given `RowSet` to map column to properties of the `targetType` or prototype bean. - +