This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
3 Replies Last post: Aug 19, 2008 7:13 PM by Serge Piletsky  
Heinrich Wendel   7 posts since
Aug 14, 2008
Currently Being Moderated

Aug 18, 2008 11:15 AM

JExcel Read Performance

Hi,

 

I want to read approximately 3500 Lines, each Line 4 Cells in a Workbook, this take about 8 seconds here. Is there a way to improve this performance.Here an outline of my sourcecode:

 

            Application myApplication = new Application();

            Workbook myWorkbook = myApplication.openWorkbook(myTempFile);

            Worksheet sheet = myWorkbook.getWorksheet("Outputs");

            final int rowCount = sheet.getUsedRange().getRowCount();

 

            for (int i = 9; i < rowCount; i++) {

                String value = sheet.getCell(i, 7).getString();

                if (value != null && !value.equals("-")) {

                    IDMParameter p = new IDMParameter();

                    p.setName(sheet.getCell(i, 2).getString());

                    p.setDescription(sheet.getCell(i, 1).getString());

                    p.setValue(value);

                    p.setUnit(sheet.getCell(i, 5).getString());

                    p.setRowId(i);

                    parameters.add(p);

                }

            }

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
1. Aug 19, 2008 6:58 PM in response to: Heinrich Wendel
Re: JExcel Read Performance

Hi Heinrich,

 

Please try the new build of JExcel: ftp://ftp.teamdev.com/updates/jexcel-1.2.902.jar In this update we have added new methods in Range class that you can use to improve the reading performance:

    /**
     * Bulk operation method. It allows fast values extraction
     * from worksheet range as a 2D Variant array [cols][rows]
     *
     * @return array of Variants from the range
     */
    public Variant[][] getValues()

 

The usage of this new function is quite simple:

Application myApplication = new Application();
Workbook myWorkbook = myApplication.openWorkbook(myTempFile);
Worksheet sheet = myWorkbook.getWorksheet("Outputs");
Range range = sheet.getUsedRange();
Variant[][] values = range.getValue();

 

Then you will need to iterate by this 2-dimensional array and get the values from Variant objects. The value of Variant object depends on the cell type. But the general approach is following:

Variant[][] values = ;
Variant variant = values+[j];
String stringPresentation = variant.getValue().toString()

 

Please try this solution and let us know the results.

 

-Serge

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
3. Aug 19, 2008 7:13 PM in response to: Heinrich Wendel
Re: JExcel Read Performance

Yes, here it is: ftp://ftp.teamdev.com/updates/jexcel-1.2-full.902.jar

 

Please let me know if you have any further questions.

 

-Serge

More Like This

  • Retrieving data ...