Skip to content

Add support for MS excel format using Apache POI #123

Closed

Description

@fmbenhassine

Add reader and writer for MS Excel format using Apache POI

Activity

  1. self-assigned this
    on Aug 11, 2015
  2. added this to the milestone on Aug 11, 2015
  3. modified the milestones: 4.1.0, 4.0.0 on Nov 7, 2015
  4. sothavirak commented on Nov 9, 2015

    @sothavirak

    Hi, when this feature is released? I actually implemented my own Ms excel reader which can support both xls and xlsx.

  5. added a commit that references this issue on Nov 9, 2015
  6. fmbenhassine commented on Nov 9, 2015

    @fmbenhassine
    MemberAuthor

    Hi,

    There is no due date, it depends on the progress. There is a branch named easybatch-msexcel where I am experimenting with Apache POI. See example here.

    Here is the current status of the branch:

    • MsExcelRecord
    • MsExcelRecordReader
    • MsExcelRecordMapper
    • MsExcelRecordMarshaller
    • MsExcelRecordWriter

    You can already try it by importing the 4.1.0-SNAPSHOT version in your project.

    The current reader supports only xls format, you are welcome to add support for xlsx from your implementation.

    BTW, are you using the latest version 4.0? If not, I strongly recommend you to upgrade, this is the best release so far! I would love to hear your thoughts on this new version :-)

    Regards
    Mahmoud

  7. sothavirak commented on Nov 10, 2015

    @sothavirak

    Hi Mahmoud,

    Yes we are using version 4.0 and we love it :)... As for xlsx support, our requirement is to be able to read both format by replacing one line in your MsExcelRecordReader.java

    HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));

    with

    Workbook workbook = WorkbookFactory.create(new FileInputStream(file));

    Thanks for the great work. This framework is rock!

    Regards,
    Sothavirak

  8. fmbenhassine commented on Nov 10, 2015

    @fmbenhassine
    MemberAuthor

    Thank you for this kind feedback! I'm glad you like it :-)

    I was thinking about making the MsExcel format as a second parameter to the MsExcelRecordReader:

    File tweets = new File("tweets.xls");
    Job job = JobBuilder.aNewJob()
          .reader(new MsExcelRecordReader(tweets , MsExcelFormat.XLS)) // or MsExcelFormat.XLSX
          .build();
    

    Or may be other names for the constants, but the idea is to make the format configurable at construction time to support both versions.

    The work is in progress, keep tuned. You are welcome to contribute if you want!

    Kind regards
    Mahmoud

  9. added a commit that references this issue on May 26, 2016
  10. fmbenhassine commented on May 26, 2016

    @fmbenhassine
    MemberAuthor

    Hi Sothavirak,

    It took some time, but it is finally here 😄 I've added support for MsExcel XLSX support in the master branch and will be released soon. Here are the main components:

    • MsExcelRecord: record having apache POI Row as payload
    • MsExcelRecordReader: iteratively read MsExcelRecords from a xlsx file
    • MsExcelRecordMapper: map rows to POJOs
    • MsExcelRecordMarshaller: marshal POJOs to rows
    • MsExcelRecordWriter: write rows to a sheet in a xlsx file

    I've decided to support only the new format (xlsx) but not the legacy one (xls).
    Looks like apache POI provide two APIs for reading data: eventmodel (ala SAX) and usermodel (in memory). I've used the usermodel for now, which is fine for small to medium files. I'll add streaming support later on for large input files.

    It would be great if you can try it with version 4.1.0-SNAPSHOT and give me your feedback. An example can be found here.

    Kind regards
    Mahmoud

  11. fmbenhassine commented on Jun 12, 2016

    @fmbenhassine
    MemberAuthor

    I'm preparing to release v4.1 including this feature.

    If you have any issue, please file a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions