Control the Conversion of Large Numeric Value to Exponential Notation, Delete Redundant Spaces from HTML and Detect if a Cell Value Starts with Single Quote using Aspose.Cells for .NET 8.8.0

Aspose.Cells for .NET logoWe are pleased to announce our next version of Aspose.Cells for .NET v8.8.0. This release contains some valuable features along with critical bug fixes and other enhancements. Please see the release notes in order to get an idea on what is new and what has been fixed with this version of Aspose.Cells for .NET. 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 APIs are changed so far. We have highlighted some important features and other enhancements here.

Control the Conversion of Large Numeric Value to Exponential Notation

As per default behaviour, if a numeric value is larger than the threshold, the API converts such values to exponential notation while importing HTML segment/files to Aspose.Cells object model. In past, we could use the HTMLLoadOptions.ConvertNumericData property to control the conversion of textual values to numeric data, however, this approach has its own drawbacks. For instance, if there are more than one columns containing the numeric values, setting the HTMLLoadOptions.ConvertNumericData property to false will direct the Aspose.Cells APIs to keep all values in textual format. In such case, all formatting from the numeric values will be lost.

In order to handle the situations where users wish to retain the format of all numeric values as well as keep the data in its original state, the Aspose.Cells for .NET 8.8.0 has exposed the HTMLLoadOptions.KeepPrecision property. The Boolean property allows to control the conversion of large numeric values to exponential notation. When set to true, the numeric values larger than 15 digits will be imported as it is.

Here is the simple usage scenario demonstrating the usage of HTMLLoadOptions.KeepPrecision property to avoid the conversion of large numbers to exponential notation while importing data from Html.

//Sample Html containing large number with digits greater than 15
string html = "1234567890123456";

//Convert Html to byte array
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(html);

//Set Html load options and keep precision true
HTMLLoadOptions loadOptions = new Aspose.Cells.HTMLLoadOptions(LoadFormat.Html);
loadOptions.KeepPrecision = true;

//Convert byte array into stream
MemoryStream stream = new MemoryStream(byteArray);

//Create workbook from stream with Html load options
Workbook workbook = new Workbook(stream, loadOptions);

Delete Redundant Spaces from HTML

Aspose.Cells for .NET 8.8.0 has exposed the HTMLLoadOptions.DeleteRedundantSpaces property to control the preservation of redundant spaces after the line break tag (<BR> tag) in HTML. If the aforementioned property is set to true the API will delete all the redundant spaces while importing the HTML in Aspose.Cells object mode. The HTMLLoadOptions.DeleteRedundantSpaces property has the default value as false, that means, all the redundant spaces are preserved in the resultant spreadsheet.

Detect if Cell Value Starts with Single Quote

Aspose.Cells for .NET 8.8.0 has exposed the Style.QuotePrefix property to detect if the cell value starts with single quote mark. With previous versions of Aspose.Cells APIs, it was not possible to distinguish between the text values, such as sample and ‘sample.

Here is the simple usage scenario of Style.QuotePrefix property to find if the cell value starts with single quote mark.

//Create workbook
Workbook wb = new Workbook();

//Create worksheet
Worksheet sheet = wb.Worksheets[0];

//Access cell A1 and A2
Cell a1 = sheet.Cells["A1"];
Cell a2 = sheet.Cells["A2"];

//Add sample in A1 and sample with quote prefix in A2

//Print their string values, A1 and A2 both are same
Console.WriteLine("String value of A1: " + a1.StringValue);
Console.WriteLine("String value of A2: " + a2.StringValue);

//Access styles of A1 and A2
Style s1 = a1.GetStyle();
Style s2 = a2.GetStyle();


//Check if A1 and A2 has a quote prefix
Console.WriteLine("A1 has a quote prefix: " + s1.QuotePrefix);
Console.WriteLine("A2 has a quote prefix: " + s2.QuotePrefix);

Other Enhancements and Fixes

The most notable other enhancements in this release are as follows:

We have also handled a few exceptions regarding reading/writing MS Excel files, rendering Excel files to PDF and refreshing Pivot Tables.

In this release, several important issues have been addressed. For example, issues around manipulating Microsoft Excel file formats, importing and converting HTML files, manipulating and rendering shapes, rendering images from Excel worksheets, manipulating charts, rendering images files from charts and exporting Excel workbooks to PDF format have been resolved. The Aspose.Cells formula calculation engine is also enhanced in this release.

Moreover, in the new release, we have added session timeout alert in the web based grid control provided by Aspose.Cells for .NET. We also fixed a few issues regarding data validations and GridWeb’s context menu.

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