Performances on large Excel in Java

The following example shows how you can test the performance of GemBox.Spreadsheet for Java component on large spreadsheet files when using the Free version of the component.

If the limits of the free version are exceeded, the component will continue to work in Trial mode if the FreeLimitReached listener is added as in the example.

For more information about Trial mode limitations, see GemBox.Spreadsheet Evaluation and Licensing help page.

Performance of GemBox.Spreadsheet for Java on large Excel file
Screenshot of performance of GemBox.Spreadsheet for Java on large Excel file
import com.gembox.spreadsheet.*;

import java.util.concurrent.TimeUnit;

class Program {

    public static void main(String[] args) throws {
        // If using Professional version, put your serial key below.

        // If example exceeds Free version limitations then continue as Trial version:
        SpreadsheetInfo.addFreeLimitReachedListener((event) -> event.setFreeLimitReachedAction(FreeLimitReachedAction.CONTINUE_AS_TRIAL));

        int rowCount = 50000;
        int columnCount = 10;
        String fileFormat = "XLSX";

        System.out.println("Performance example:");
        System.out.println("Row count: " + rowCount);
        System.out.println("Column count: " + columnCount);
        System.out.println("File format: " + fileFormat);

        long start = System.nanoTime();

        ExcelFile workbook = new ExcelFile();
        ExcelWorksheet worksheet = workbook.addWorksheet("Performance");

        for (int row = 0; row < rowCount; row++)
            for (int column = 0; column < columnCount; column++)
                worksheet.getCell(row, column).setValue(row + "_" + column);

        long elapsed = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
        System.out.println("Generate file (seconds): " + elapsed / 1000.0);

        start = System.nanoTime();

        int cellsCount = 0;
        for (ExcelRow row : worksheet.getRows())
            for (ExcelCell cell : row.getAllocatedCells())

        elapsed = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
        System.out.println("Iterate through " + cellsCount + " cells (seconds): " + elapsed / 1000.0);

        start = System.nanoTime();"Report." + fileFormat.toLowerCase());

        elapsed = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);

        System.out.println("Save file (seconds): " + elapsed / 1000.0);

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.

Like it?

Download Buy

If you want to try the GemBox.Spreadsheet for Java yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.