Control external resources embedded in the document, Filter defined names while loading Workbook and other enhancements in Aspose.Cells for .NET 18.2

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn


Aspose.Cells for .NET logo
We are pleased to announce the release of Aspose.Cells for .NET v18.2. Please check the document on how to install Aspose for .NET APIs directly from NuGet repository. In this release, we have added a few valuable features for the users. For example, we included support to control/manage external resources embedded in the Excel document. You can filter formulas and defined names separately when loading Excel spreadsheets. Some other enhancements are also added regarding shapes. Please check the release notes in order to get an idea about what is new and what has been enhanced or fixed with this revision of Aspose.Cells for .NET.

Control External Resources using WorkbookSetting.StreamProvider

If your Excel file contains external resources e.g. linked images etc. and you need to control these external resources, Aspose.Cells supports to manage external resources using Workbook.Settings.StreamProvider which takes the implementation of IStreamProvider interface. Whenever you will try to render your worksheet containing external resources, the methods of IStreamProvider interface will be invoked which will enable you to take appropriate actions for your external resources. The following snippet loads an Excel file (containing a linked image). The code replaces the linked image with Aspose Logo and renders the entire sheet into a single image using SheetRender class.

//Implementation of IStreamProvider
class SP : IStreamProvider
{
    public void CloseStream(StreamProviderOptions options)
    {
 
    }
 
    public void InitStream(StreamProviderOptions options)
    {
        //Open the filestream of Aspose Logo and assign it to StreamProviderOptions.Stream property
        FileStream fi = new FileStream("sampleLogo_WorkbookSetting_StreamProvider.png", FileMode.OpenOrCreate, FileAccess.Read);
        options.Stream = fi;
    }
}
 
//-------------------------------------------------
//-------------------------------------------------
 
static void Run()
{
    //Load sample Excel file containing the external resource e.g. linked image etc.
    Workbook wb = new Workbook("sampleControlExternalResourcesUsingWorkbookSettingStreamProvider.xlsx");
 
    //Provide your implementation of IStreamProvider
    wb.Settings.StreamProvider = new SP();
 
    //Access first worksheet
    Worksheet ws = wb.Worksheets[0];
 
    //Specify image or print options, we need one page per sheet and png output
    ImageOrPrintOptions opts = new ImageOrPrintOptions();
    opts.OnePagePerSheet = true;
    opts.ImageFormat = ImageFormat.Png;
 
    //Create sheet render by passing required parameters
    SheetRender sr = new SheetRender(ws, opts);
 
    //Convert your entire worksheet into png image
    sr.ToImage(0, "outputControlExternalResourcesUsingWorkbookSettingStreamProvider.png");
}

Please see the document/article with attachment(s) on how to control external resources embedded in an Excel worksheet for your reference.

Filter Defined Names while loading Workbook

Aspose.Cells now allows you to filter/exclude defined names present inside the workbook while loading the spreadsheet. You may use LoadDataFilterOptions.DefinedNames to load defined names and use ~LoadDataFilterOptions.DefinedNames to remove them while loading the workbook. For more detail on the feature, please see this article/document for your reference.

Set Margins of Comment or Shape inside the Worksheet

Using Aspose.Cells APIs, you can set the margins of any shape including comments using the Shape.TextBody.TextAlignment property. This property returns the object of Aspose.Cells.Drawing.Texts.ShapeTextAlignment class which has different properties e.g. TopMarginPt, LeftMarginPt, BottomMarginPt, RightMarginPt etc. that can be used to set the top, left, bottom and right margins. For more detail, please see this article.

Specify Formula Fields while Importing Data to Worksheet

You can specify formula fields when you import data into your worksheet using the ImportTableOptions.IsFormulas. This property takes the Boolean array where the value true means the field is a formula field. For example, if the third field is a formula field, then third value in the array will be true. For more detail, please see this article.

Specify Maximum Rows of Shared Formula

Aspose.Cells provides the Workbook.Settings.MaxRowsOfSharedFormula property that can be used to specify the maximum rows of the shared formula. The shared formula will be split to several shared formulas if the total rows of shared formula is greater than it. For more detail, please see this article.

Other Enhancements and Fixes

There are some other enhancements included and a few exception handled in the new release for the users. A few of the worth mentioning features and other enhancements are as follows.

  • Implemented Aspose.Cells for .NET Standard and Aspose.Cells for .NET Core.
  • And enhancement is made:=cmd|' /c calc'!A0is not present inside Worksheets.ExternalLinks.
  • Mimic behavior of MS Excel when entering text (while wrapping text is enabled) into Aspose.Cells.GridWeb.
  • Handled an exception “Input string was not in a correct format” when importing the Excel file into Aspose.Cells.GridWeb.

In Aspose.Cells 18.2, we fixed several important bugs and other issues. For example, issues around reading/writing MS Excel file formats, rendering Excel to HTML and vice versa, manipulating shapes, Smart Markers, using PageSetup options, rendering and manipulating charts, manipulating PivotTables, rendering images from Excel worksheets, rendering images files from charts and exporting Excel workbooks to PDF format have been resolved. Moreover, the Aspose.Cells formula calculation engine is further optimized.

Changes to the Public API

This version of Aspose.Cells for .NET has made some changes to the Public API. A few of the worth mentioning changes are as follow:

  • Added LoadDataFilterOptions.DefinedNames enum member, it indicates whether loading defined Name objects when loading template file.
  • Added SheetType.Dialog enum member, it represents dialog sheet.
  • Added WorkbookSettings.MaxRowsOfSharedFormula property, it gets and sets the max row number of shared formula. The shared formula will be split to several shared formula if the total rows of shared formula is greater than it.
  • Added ImportTableOptions.IsFormulas property, it represents which column in the datatable should be imported as formulas.

Aspose.Cells for .NET Resources

The resources, you may need to accomplish your tasks: