Read Large Excel Files with LightCells API and Find Cells Based on Formatting in Aspose.Cells for Java 7.7.1

Share on FacebookTweet about this on TwitterShare on LinkedIn

Aspose.Cells for Java logoWe are pleased to announce the release of Aspose.Cells for Java 7.7.1 with certain new features, enhancements and other bug fixes. This new release supports reading large Excel files with LightCells API. This is a useful feature. Sometimes you need to read data from a huge Microsoft Excel workbook with  millions of records and you are always worried about the performance. You want it to take less time and memory to process big files. The LightCells API is useful in that scenario: to read huge Excel spreadsheets, it uses less memory, so you get better performance and efficiency.

The following sample code shows how to load an Excel file in light-weight mode. The sample code reads a big file and retrieves the total number of cells, a count of strings and a count of formulas for each worksheet in the workbook.

import java.io.*;
import java.util.*;

import com.aspose.cells.*;

public class LightCellsTest1
{
	public static void main(String[] args)throws Exception
	{
	    LoadOptions opts = new LoadOptions();
            LightCellsDataHandlerVisitCells v = new LightCellsDataHandlerVisitCells();
            opts.setLightCellsDataHandler(v);
            Workbook wb = new Workbook("e:\\test2\\LargeBook1.xlsx", opts);
            int sheetCount = wb.getWorksheets().getCount();
            System.out.println("Total sheets: " + sheetCount + ", cells: " + v.cellCount
                + ", strings: " + v.stringCount + ", formulas: " + v.formulaCount);

	}

    }

/* A class that implements LightCellsDataHandler interface
 * Copyright (c) 2001-2014 Aspose Pty Ltd. All Rights Reserved.
 */
import java.io.*;
import java.util.*;

import com.aspose.cells.*;

public class LightCellsDataHandlerVisitCells implements LightCellsDataHandler
        {
            public int cellCount;
            public int formulaCount;
            public int stringCount;

            public LightCellsDataHandlerVisitCells()
            {
                this.cellCount = 0;
                this.formulaCount = 0;
                this.stringCount = 0;
            }

            public int cellCount()
            {
                 return cellCount;
            }

            public int formulaCount()
            {
                return formulaCount;
            }

            public int stringCount()
            {
                return stringCount;
            }

            public boolean startSheet(Worksheet sheet)
            {
                System.out.println("Processing sheet[" + sheet.getName() + "]");
                return true;
            }

            public boolean startRow(int rowIndex)
            {
                return true;
            }

            public boolean processRow(Row row)
            {
                return true;
            }

            public boolean startCell(int column)
            {
                return true;
            }

            public boolean processCell(Cell cell)
            {
                this.cellCount = this.cellCount +1;
                if (cell.isFormula())
                {
                    this.formulaCount = this.formulaCount+ 1;
                }
                else if (cell.getType() == CellValueType.IS_STRING)
                {
                    this.stringCount = this.stringCount +1;
                }
                return false;
            }
      }

Finding Cells Based on Formatting

Another valuable feature is to find the cells with some particular style or formatting. Aspose.Cells supports finding all cells that have a common style or formatting. Aspose.Cells provides the FindOptions.setStyle() method which you can use to specify the style to search cells for.

Transparent Images

You can now create transparent images of Microsoft Excel worksheet. Sometimes, you need to generate an image of your worksheet as a transparent image. For example, you might want to apply transparency to all the cells which have no fill color. Aspose.Cells provides the ImageOrPrintOptions.setTransparent() method which applies transparency to a  worksheet image.

We have added support to parse/ read ActiveX controls in the template files. We have also added a number of enhancements in the new release. In this version, we have refactored the PivotTables module. We’ve made tremendous enhancements and fixed several issues.

We have improved the chart to image and sheet to image modules. In this release, we have fixed the issues with manipulating charts and shapes. Several other important issues have also been addressed. For example, issues to do with rendering Microsoft Excel file formats, rendering images from Excel worksheets, rendering shapes and controls data and exporting Excel workbooks to PDF format have been resolved.

To see a complete list of enhancements and fixes and to download Aspose.Cells for Java 7.7.1, please visit the download page.