Amjad Sahi January 20, 2014one Comment

Read Large Excel Files with LightCells API and Create Transparent Images from Worksheets in Aspose.Cells for .NET 7.7.1

Read Large Excel Files with LightCells API and Create Transparent Images from Worksheets in Aspose.Cells for .NET 7.7.1

January 20, 2014
Share on FacebookTweet about this on TwitterShare on LinkedIn

Aspose.Cells for .NET logoAspose.Cells for .NET 7.7.1 has been released with over 80 useful new features, enhancements and 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 always worry 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.

 static void Main(string[] args)
        {
            LoadOptions opts = new LoadOptions();
            LightCellsDataHandlerVisitCells v = new LightCellsDataHandlerVisitCells();
            opts.LightCellsDataHandler = v;
            Workbook wb = new Workbook("LargeBook1.xlsx", opts);
            int sheetCount = wb.Worksheets.Count;
            Console.WriteLine("Total sheets: " + sheetCount + ", cells: " + v.CellCount
                + ", strings: " + v.StringCount + ", formulas: " + v.FormulaCount);
        }

    class LightCellsDataHandlerVisitCells : LightCellsDataHandler
        {
            private int cellCount;
            private int formulaCount;
            private int stringCount;

            internal LightCellsDataHandlerVisitCells()
            {
                cellCount = 0;
                formulaCount = 0;
                stringCount = 0;
            }

            public int CellCount
            {
                get { return cellCount; }
            }

            public int FormulaCount
            {
                get { return formulaCount; }
            }

            public int StringCount
            {
                get { return stringCount; }
            }

            public bool StartSheet(Worksheet sheet)
            {
                Console.WriteLine("Processing sheet[" + sheet.Name + "]");
                return true;
            }

            public bool StartRow(int rowIndex)
            {
                return true;
            }

            public bool ProcessRow(Row row)
            {
                return true;
            }

            public bool StartCell(int column)
            {
                return true;
            }

            public bool ProcessCell(Cell cell)
            {
                cellCount++;
                if (cell.IsFormula)
                {
                    formulaCount++;
                }
                else if (cell.Type == CellValueType.IsString)
                {
                    stringCount++;
                }
                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.Style property 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.Transparent property which applies transparency to a  worksheet image. When this property is false, then the cells with no fill color are drawn with white background, and when it is true, cells with no fill color are rendered transparent.

Several Enhancements and Fixes

In this version, we have refactored the PivotTables module. We’ve made tremendous enhancements and fixed several issues.

Several important issues and other enhancements have been addressed in this release as well. For example, issues around reading and writing Microsoft Excel file formats, manipulating conditional formattingrendering and manipulating pivot tables, rendering images from Excel worksheets, reading and writing HTML files, rendering shapes and controls, Smart Markers, manipulating embedded OLE objects, rendering and manipulating charts, rendering images files from charts and exporting Excel workbooks to PDF format have been resolved. A few improvements are also made pertaining to the formula calculation engine of Aspose.Cells for .NET, it now supports the BITAND  function (Microsoft Excel 2013).

We have also made a few enhancements in the grid suite provided by Aspose.Cells for .NET. Now, you can import or load bigger Excel files.

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

Join the Conversation

1 Comment

Leave a comment

Posted inAspose.Cells Product FamilyTags: , , , , , , , , , , , , , ,
 

Related Articles