Public API Changes in Aspose.Cells 8.8.3

Added APIs

Support for ActiveX Controls

Aspose.Cells for Java 8.8.3 has exposed the addActiveXControl method that allows you to add an ActiveX control to the ShapeCollection. The aforementioned method requires seven parameters to specify the control type, the location to place the control, and the size of the control. The type can be specified using the ControlType enumeration with the following possible values.

  1. ControlType.CHECK_BOX
  2. ControlType.COMBO_BOX
  3. ControlType.COMMAND_BUTTON
  4. ControlType.IMAGE
  5. ControlType.LABEL
  6. ControlType.LIST_BOX
  7. ControlType.RADIO_BUTTON
  8. ControlType.SCROLL_BAR
  9. ControlType.SPIN_BUTTON
  10. ControlType.TEXT_BOX
  11. ControlType.TOGGLE_BUTTON
  12. ControlType.UNKNOWN

Following is the simple usage scenario.

Java

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

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

//Add Toggle Button ActiveX Control to the ShapeCollection at specified location
Shape shape = sheet.getShapes().addActiveXControl(ControlType.TOGGLE_BUTTON, 4, 0, 4, 0, 100, 30);

//Access the ActiveX Control object and set its linked cell property
ActiveXControl control = shape.getActiveXControl();
control.setLinkedCell("A1");

//Save the result on disk
book.save(dir + "output.xlsx", SaveFormat.XLSX);

Added LoadOptions.setPaperSize Method

Aspose.Cells for Java 8.8.3 allows you to set the default print paper size from the default printer’s setting while using the newly exposed LoadOptions.setPaperSize method as demonstrated below. Please note, the input parameter to the aforementioned method is a value from the PaperSizeType enumeration containing the predefined paper sizes.

Following is the simple usage scenario.

Java

 //Create an instance of LoadOptions
LoadOptions loadOptions = new LoadOptions();

//Set the PaperSize property to the appropriate value
loadOptions.setPaperSize(PaperSizeType.PAPER_A_4);

//Create an instance of Workbook and load an existing spreadsheet
Workbook book = new Workbook(dir + "input.xlsx", loadOptions);

Added Cell.getCharacters(flag) Method

Aspose.Cells APIs allow you to get the character objects in the form of a FontSetting array by using the Cell.getCharacters method. With this release, the Aspose.Cells for Java API has exposed an overloaded version of Cell.getCharacters that can accept a Boolean parameter, indicating whether the table style has to be applied to the cell if the cell is part of a ListObject.

Java

 //Create an instance of Workbook and load an existing spreadsheet
Workbook book = new Workbook(dir + "input.xlsx");

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

//Access cells collection of the first worksheet
Cells cells = sheet.getCells();

//Access particular cell from a ListObject
//Assuming A1 resides in a ListObject
Cell cell = cells.get("A1");

//Get all character objects from the cell
FontSetting[] characters = cell.getCharacters(true);

Added OleObject.AutoLoad Property

Aspose.Cells for Java 8.8.3 has exposed the OleObject.AutoLoad property which allows you to refresh the OleObject’s image if the contents/data of the underlying object have been changed. The property, when set to true, forces the Excel application to refresh the OleObject’s image when the resultant spreadsheet is loaded.

Following is the simple usage scenario.

Java

 //Create an instance of Workbook and load an existing spreadsheet
Workbook book = new Workbook(dir + "input.xlsx");

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

//Access OleObjectCollection from first worksheet
OleObjectCollection oleObjects = sheet.getOleObjects();

//Access an OleObject from the collection
OleObject oleObject = oleObjects.get(0);

//Set AutoLoad to true
oleObject.setAutoLoad(true);

Added HTMLLoadOptions.SupportDivTag Property

Aspose.Cells for Java 8.8.3 has exposed the HTMLLoadOptions.SupportDivTag property which allows you to parse the <div> tags embedded in <td> tags while loading HTML files/snippets in the Aspose.Cells object model. This Boolean‑type property has a default value of false.

Following is the simple usage scenario.

Java

 //Store the HTML snippet in a variable
String export_html = "<html>"
    + "<body>"
    + " <table>"
    + "     <tr>"
    + "         <td>"
    + "             <div>This is some Text.</div>"
    + "             <div>"
    + "                 <div>"
    + "                     <span>This is some more Text</span>"
    + "                 </div>"
    + "                 <div>"
    + "                     <span>abc@abc.com</span>"
    + "                 </div>"
    + "                 <div>"
    + "                     <span>1234567890</span>"
    + "                 </div>"
    + "                 <div>"
    + "                     <span>ABC DEF</span>"
    + "                 </div>"
    + "             </div>"
    + "             <div>Generated On May 30, 2016 02:33 PM <br />Time Call Received from Jan 01, 2016 to May 30, 2016</div>"
    + "         </td>"
    + "         <td>"
    + "             <img src='ASpose_logo_100x100.png' />"
    + "         </td>"
    + "     </tr>"
    + " </table>"
    + "</body>"
    + "</html>";

//Convert HTML string to InputStream
InputStream stream = new ByteArrayInputStream(export_html.getBytes(StandardCharsets.UTF_8));

//Create an instance of HTMLLoadOptions
HTMLLoadOptions loadOptions = new HTMLLoadOptions(LoadFormat.HTML);

//Set SupportDivTag property to true
loadOptions.setSupportDivTag(true);

//Create workbook object from the HTML using load options
Workbook book = new Workbook(stream, loadOptions);

//Save the spreadsheet on disk
book.save(dir + "output.xlsx", SaveFormat.XLSX);

Added HtmlSaveOptions.ExportGridLines Property

Aspose.Cells for Java 8.8.3 has exposed the HtmlSaveOptions.ExportGridLines property which allows you to render the grid lines while exporting a spreadsheet to HTML format. This Boolean‑type property has a default value of false; however, when set to true, the API renders the grid lines for the available data range in HTML format.

Following is the simple usage scenario.

Java

 //Create an instance of Workbook and load existing spreadsheet
Workbook book = new Workbook(dir + "input.xlsx");

//Create an instance of HtmlSaveOptions
HtmlSaveOptions options = new HtmlSaveOptions();

//Set ExportGridLines to true
options.setExportGridLines(true);

//Save the result in HTML format
book.save(dir + "output.html", options);

Added ListObject.Comment Property

Aspose.Cells APIs now allow you to get and set the comments for an instance of ListObject. In order to provide the aforementioned feature, the Aspose.Cells APIs have exposed the ListObject.Comment property.

Following is the simple usage scenario.

Java

 //Create an instance of Workbook and load existing spreadsheet
Workbook book = new Workbook(dir + "input.xlsx");

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

//Access first ListObject from the collection of ListObjects
ListObject listObject = sheet.getListObjects().get(0);

//Set comments for the ListObject
listObject.setComment("Comments");

//Save the result on disk
book.save(dir + "output.xlsx");

Removed APIs

Removed Workbook.decrypt Method

The property was marked obsolete some time back. This release has completely removed it from the public API. It is advised to set the WorkbookSettings.Password property to null in order to achieve the same goal.