Optimize Excel to PDF File Size and Add Digital Signatures for VBA Projects using C#

Aspose.Cells for .NET logo

Aspose.Cells for .NET 8.7.0 has been released. This release contains some useful features and other enhancements along with critical bug fixes. If you are planning to upgrade the Aspose.Cells for .NET API to the latest revision, we would strongly suggest you to check the complete Public API Changes section to know what has been changed in the API so far. We have highlighted some important features (of this month’s release) here.

While you are downloading the latest build, here is a look at the biggest features in this release.

Optimize Excel to PDF File Size using C#

Aspose.Cells APIs have provided an enhancement for the PDF rendering engine in order to reduce the resultant PDF file size. Aspose.Cells for.NET 8.7.0 has exposed the PdfSaveOptions.OptimizationType property along with an enumeration by the name PdfOptimizationType in order to facilitate the application developers to control the resultant PDF file size to a certain extent.

The PdfOptimizationType enumeration has 2 constants at the moment exhibiting the following behavior.

  1. PdfOptimizationType.MinimumSize: API tries to optimize the cell text and cell border records in order to reduce the resultant PDF file size.
  2. PdfOptimizationType.Standard: No optimization is done therefore the resultant file size will be large as compared to PdfOptimizationType.MinimumSize selection.

The following piece of code demonstrates the usage of PdfSaveOptions.OptimizationType property to minimize the resultant PDF file size while exporting spreadsheets to PDF format.

Re-size Chart’s Data Label Shape to Fit Text

Aspose.Cells for .NET 8.7.0 has exposed the Boolean type DataLabels.IsResizeShapeToFitText property in order to mimic Excel’s feature of re-sizing data label shapes to fit the text.

Please note, Excel application provides the Resize shape to fit text option for chart’s data labels to increase the size of the shape so that the text fits inside of it. This option can be accessed on an Excel interface by selecting any of the data labels on the chart. Right-click and select Format DataLabels menu. On Size & Properties tab, expand Alignment node to reveal the related properties including the Resize shape to fix text option as highlighted below.

The following piece of code shows the simple usage scenario of DataLabels.IsResizeShapeToFitText property to re-size the chart’s data label shapes to fit text.

Here is a snapshot showing a simple bar chart before & after executing the above code.

Enhancements to Protection Module

Aspose.Cells APIs have enhanced the Protection class by introducing some useful properties & methods. Two of the most worth mentioning enhancements are as follow.

Detect if Worksheet is Password Protected

It is possible to protect the workbooks and worksheets separately. For instance, a spreadsheet may contain one or more worksheets that are password-protected, however, the spreadsheet itself may or may not be protected. Aspose.Cells API for Java has provided the Protection.IsProtectedWithPassword field to detect if a worksheet is password protected. Boolean type Protection.IsProtectedWithPassword field returns true if Worksheet is password protected and false if not.

Verify Password Used to Protect the Worksheet

Aspose.Cells for .NET 8.7.0 has exposed the Protection.VerifyPassword method which allows to specify a password as an instance of String and verifies if same password has been used to protect the worksheet. The Protection.VerifyPassword method returns true if the specified password matches with the password used to protect the given Worksheet, false if specified password does not match.

The following piece of code uses the Protection.VerifyPassword method in conjunction with Protection.IsProtectedWithPassword field to detect the password protection and verifies the password.

Load or Import Delimited File Containing Formulas

Aspose.Cells for .NET has provided support to identify & parse the formulas while loading CSV/TXT files having delimited plain data. Newly exposed TxtLoadOptions.HasFormula property when set to true directs the API to parse the formulas from the input delimited file and set them to relevant cells without requiring any additional processing.

The following piece of code demonstrates the usage of TxtLoadOptions.HasFormula property to load and import the CSV with formulas in it.

Create 2-Color Scale Conditional Format

This release of the API has exposed the ColorScale.Is3ColorScale property that can be used to create a 2-Color Scale conditional format. The said property is of type boolean with the default value of true which means that the conditional format will be of 3-Color Scale by default. However, switching the ColorScale.Is3ColorScale property to false will generate a 2-Color Scale conditional format.

Please see the detailed article on Adding 2 & 3-Color Scale Conditional Formatting.

Other Enhancements & Fixes

The most notable enhancements in this release are as follow:

We have handled a few exceptions regarding reading/writing Excel files and rendering PivotTables and HTML file format.

In this release, several important issues have been addressed. For example, issues around manipulating Microsoft Excel file formats, manipulating Pivot Tables, applying styles, conditional formatting, rendering images from Excel worksheets, manipulating charts, rendering images files from charts and exporting Excel workbooks to PDF format have been resolved. We have further enhanced the Aspose.Cells formula calculation engine and fixed a few issues in this regard.

Moreover, in the new release, we have also fixed a few issues in the web-based grid control provided by Aspose.Cells for .NET.

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