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

How to read multi sheets every sheet into separated lists? #17

Closed
saraselim1 opened this issue May 12, 2019 · 3 comments
Closed

How to read multi sheets every sheet into separated lists? #17

saraselim1 opened this issue May 12, 2019 · 3 comments
Assignees
Labels

Comments

@saraselim1
Copy link

How to read multi sheets every sheet into separated lists?

@millij millij self-assigned this May 13, 2019
@millij
Copy link
Owner

millij commented May 13, 2019

@saraselim1
There is API to read by sheet no.
You just need to pass the sheet number as third argument to read method.
Check below for usage..

    ...
    final File xlsxFile = new File("<path_to_file>");
    final XlsReader reader = new XlsReader();
    List<Employee> employees = reader.read(Employee.class, xlsxFile, <sheet_no>);
    ...

As each sheet read is independent of other, each sheet can be mapped to different Class. Something like below..

    ...
    final File xlsxFile = new File("<path_to_file>");
    final XlsReader reader = new XlsReader();
    
    // Sheet 1 is mapped to Teacher.class 
    List<Teacher> teachers = reader.read(Teacher.class, xlsxFile, 1);
    
    // Sheet 2 is mapped to Student.class
    List<Student> students = reader.read(Student.class, xlsxFile, 2);
    ...

Hope this helps. Will add this to Documentation.

@millij millij pinned this issue May 13, 2019
@saraselim1
Copy link
Author

Dear @millij
What if I want to read get the sheet by its name, not number?

@millij
Copy link
Owner

millij commented May 17, 2019

@saraselim1
We don't have any API in SpreadsheetReader to read sheet by it's name.
As it's a valid request, will take this up in the next release..

@millij millij closed this as completed Oct 24, 2020
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