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

Does it has low memory footprint ? #5

Open
danmaidesenling opened this issue Jun 4, 2018 · 7 comments
Open

Does it has low memory footprint ? #5

danmaidesenling opened this issue Jun 4, 2018 · 7 comments
Assignees
Labels

Comments

@danmaidesenling
Copy link

No description provided.

@jeevatkm jeevatkm self-assigned this Jun 4, 2018
@jeevatkm
Copy link
Owner

jeevatkm commented Jun 4, 2018

@danmaidesenling I believe so. Just released v1.3 to maven central. Please give it try.

@danmaidesenling
Copy link
Author

danmaidesenling commented Jun 5, 2018

your code on this:

ExcelWorkSheetRowCallbackHandler sheetRowCallbackHandler = new ExcelWorkSheetRowCallbackHandler(new ExcelRowContentCallback() {
    @Override
    public void processRow(int rowNum,    Map<String, String> map) {
        // Do any custom row processing here, such as save
        // to database
        // Convert map values, as necessary, to dates or
        // parse as currency, etc
        System.out.println("rowNum=" + rowNum + ", map=" + map);
    }
});

you said that Convert map values, as necessary, to dates or parse as currency, etc.
BUT What type to convert? I mean How to know the data_type of the cell

@jeevatkm
Copy link
Owner

jeevatkm commented Jun 5, 2018

Typically, you have to know the structure (no. of columns, column names, etc) and excel column type information. POI doesn't provide type information.

Example 1:

There is a excel file you're reading that has 3 columns -

  • column 1: Row number, integer
  • column 2: Full Name, string
  • column 3: join date, date type

Per your requirement you have process it.

Example 2:

Let's say excel file has 50 columns, but per your requirements, you need 4 columns., etc.

@danmaidesenling
Copy link
Author

Actually, POI has provided type information . You can see it in WorkBook

@jeevatkm
Copy link
Owner

jeevatkm commented Jun 6, 2018

Could you provide more specific details? that would be helpful.

@danmaidesenling
Copy link
Author

danmaidesenling commented Jun 7, 2018

Well.,sample code like this:

Workbook wb = WorkbookFactory.create(new File("MyExcel.xls"));
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
int cellType = cell.getCellType();   //CELL_TYPE_NUMERIC = 0; CELL_TYPE_STRING = 1...

@jeevatkm
Copy link
Owner

jeevatkm commented Jun 7, 2018

Okay, I understand now what you meant. And what I meant was java data types not a excel cell types.

FYI excelReader library handles only XSSF (.xlsx file) and provides row values as a Map. Kindly handle java type conversion at your end.

PS: feel free to PR for any improvements, thanks.

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