Public API Changes in Aspose.Cells 8.8.0

Added APIs

Get Cell References for External Connection

Aspose.Cells for Java 8.8.0 has exposed the following new properties that are helpful in retrieving the target & output cell references for external connections stored in the spreadsheet.

  1. QueryTable.ConnectionId: Gets the connection ID of the query table.
  2. ExternalConnection.Id: Gets the ID of the external connection.
  3. ListObject.QueryTable: Gets the linked QueryTable.

Added HTMLLoadOptions.KeepPrecision Property

Aspose.Cells for Java 8.8.0 has added the HTMLLoadOptions.KeepPrecision property in order to control the conversion of long numeric values to exponential notation while importing HTML files. By default, any value longer than 15 digits gets converted to exponential notation if the data is imported from an HTML string or file. However, now users can control this behavior with the help of the HTMLLoadOptions.KeepPrecision property. If the said property is set to true, the values will be imported as they are in the source.

Following is a simple usage scenario.

Java

 // Sample HTML containing large number with digits greater than 15
String html = "<html>"
        + "<body>"
        + "<p>1234567890123456</p>"
        + "</body>"
        + "</html>";

// Convert HTML to byte array
byte[] byteArray = html.getBytes();

// Set HTML load options and keep precision true
HTMLLoadOptions loadOptions = new HTMLLoadOptions(LoadFormat.HTML);
loadOptions.setKeepPrecision(true);

// Convert byte array into stream
java.io.ByteArrayInputStream stream = new java.io.ByteArrayInputStream(byteArray);

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

// Access first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);

// Auto-fit the sheet columns
worksheet.autoFitColumns();

// Save the workbook
workbook.save(dataDir + "output.xlsx", SaveFormat.XLSX);

Added HTMLLoadOptions.DeleteRedundantSpaces Property

Aspose.Cells for Java 8.8.0 has exposed the HTMLLoadOptions.DeleteRedundantSpaces property to keep or delete the extra spaces after the line break tag (
tag) while importing data from an HTML string or file. The HTMLLoadOptions.DeleteRedundantSpaces property has the default value of false, which means all extra spaces will be preserved and imported to the Workbook object; however, when set to true, the API will delete all redundant spaces that come after the line break tag.

A simple usage scenario looks as follows.

Java

 // Sample HTML containing redundant spaces after <br> tag
String html = "<html>"
        + "<body>"
            + "<table>"
                + "<tr>"
                    + "<td>"
                        + "<br>    This is sample data"
                        + "<br>    This is sample data"
                        + "<br>    This is sample data"
                    + "</td>"
                + "</tr>"
            + "</table>"
        + "</body>"
    + "</html>";

// Convert HTML to byte array
byte[] byteArray = html.getBytes();

// Set HTML load options and delete redundant spaces true
HTMLLoadOptions loadOptions = new HTMLLoadOptions(LoadFormat.HTML);
loadOptions.setDeleteRedundantSpaces(true);

// Convert byte array into stream
java.io.ByteArrayInputStream stream = new java.io.ByteArrayInputStream(byteArray);

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

// Access first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);

// Auto-fit the sheet columns
worksheet.autoFitColumns();

// Save the workbook
workbook.save(dataDir + "output-" + loadOptions.getDeleteRedundantSpaces() + ".xlsx", SaveFormat.XLSX);

Added Style.QuotePrefix Property

Aspose.Cells for Java 8.8.0 has exposed the Style.QuotePrefix property to detect if a cell value starts with a single‑quote symbol.

A simple usage scenario looks as follows.

Java

 // Create an instance of workbook
Workbook workbook = new Workbook();

// Access first worksheet from the collection
Worksheet worksheet = workbook.getWorksheets().get(0);

// Access cells A1 and A2
Cell a1 = worksheet.getCells().get("A1");
Cell a2 = worksheet.getCells().get("A2");

// Add simple text to cell A1 and text with quote prefix to cell A2
a1.putValue("sample");
a2.putValue("'sample");

// Print their string values; A1 and A2 are both the same
System.out.println("String value of A1: " + a1.getStringValue());
System.out.println("String value of A2: " + a2.getStringValue());

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

System.out.println();

// Check if A1 and A2 have a quote prefix
System.out.println("A1 has a quote prefix: " + s1.getQuotePrefix());
System.out.println("A2 has a quote prefix: " + s2.getQuotePrefix());

Obsoleted APIs

Obsoleted LoadOptions.ConvertNumericData Property

Aspose.Cells 8.8.0 has marked the LoadOptions.ConvertNumericData property as obsolete. Please use the corresponding property from the HTMLLoadOptions or TxtLoadOptions classes.