Set Link Target Type for HTML Conversion, Access & Update Portion of Rich Text and Detect If VbaProject is Signed with Aspose.Cells for Java 8.6.1

Share on FacebookTweet about this on TwitterShare on LinkedIn

Aspose.Cells for JavaAspose.Cells for Java API has been upgraded to 8.6.1, and we are pleased to announce, this month’s release contains many useful features and improvements along with some critical bug fixes. Please refer to the release notes of Aspose.Cells for Java 8.6.1 for a full list of enhancements. If you are planning to upgrade the API from any previous version, we strongly suggest you to check the Public API Changes section to know what has been changed since your current revision of the API.

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

Set Link Target Type for HTML Conversion

Aspose.Cells APIs are capable of converting all supported spreadsheet formats to HTML with highest fidelity. The conversion process is efficient as well as configurable, that is; users can customize the HTML generation process as per their application requirement. Aspose.Cells APIs have exposed the HtmlSaveOptions class that is mainly responsible for the conversion process and provides a vast array of features to influence the HTML generation.

This release of Aspose.Cells for Java API has exposed an enumeration namely HtmlLinkTargetType along with a new property HtmlSaveOptions.LinkTargetType that together allows to set the target type for the links in spreadsheet while conversion to HTML format. The possible values of the HtmlLinkTargetType enumeration are as follow where the default value is SELF.

  • HtmlLinkTargetType.BLANK: Opens the linked document/page in a new window or tab.
  • HtmlLinkTargetType.PARENT: Opens the linked document/page in parent frame.
  • HtmlLinkTargetType.SELF: Opens the linked document/page in the same frame where the link was clinked.
  • HtmlLinkTargetType.TOP: Opens the linked document/page in the full body of the window.

Here is the simplest usage scenario of newly exposed APIs to set the link target type.

//Load a spreadsheet
Workbook workbook = new Workbook(inputFilePath);

//Create an instance of HtmlSaveOptions
HtmlSaveOptions options = new HtmlSaveOptions();
//Set the LinkTargetType property to appropriate value
options.setLinkTargetType(HtmlLinkTargetType.BLANK);

//Convert the spreadsheet to HTML with preset HtmlSaveOptions
workbook.save(outputFilePath, options);

Access & Update Portion of Rich Text

Aspose.Cells for Java API provides easy to use mechanism to access the format related properties of each character from a cell containing Rich Text. The API has exposed the getCharacters & setCharacters methods for the Cell class that allows to access & update the portion of the Rich Text in a cell. The Cell.getCharacters method returns an array of FontSetting objects where each object represents the styling of an individual character. The Cell.setCharacters method also accepts an array of FontSetting objects to set the styling for individual characters of a cell.

The following sample code explains the usage of Cell.getCharacters & Cell.setCharacters methods to access and manipulate the styling of Rich Text.

//Load a spreadsheet
Workbook workbook = new Workbook(inputFilePath);
//Access first worksheet of the workbook
Worksheet worksheet = workbook.getWorksheets().get(0);
//Access the cells containing the Rich Text
Cell cell = worksheet.getCells().get("A1");

//Retrieve the array of FontSetting from the cell
FontSetting[] settings = cell.getCharacters();

//Modify the Font Name for the first FontSetting 
settings[0].getFont().setName("Arial");

//Set the updated FontSetting
cell.setCharacters(settings);

Detect If VbaProject is Signed

Aspose.Cells for Java 8.6.1 has exposed the the VbaProject.isSigned property that can be used to test if a VbaProject in a Workbook is signed or not. Boolean type property returns true if the project is signed.

Following is the simple usage scenario.

//Load a spreadsheet
Workbook workbook = new Workbook(inputFilePath);

//Retrieve the VbaProject from the Workbook
VbaProject project = workbook.getVbaProject();

//Test if VbaProject is signed
if (project.isSigned())
{
    System.out.println("VBA Project is Signed");
}
else
{
	System.out.println("VBA Project is not Signed");
}

Other Enhancements & Improvements

The most notable enhancements in this release are as follow:

  • Exposed RangeCollection.add method that can be used to add Range objects to the collection of ranges for a particular Worksheet.
  • Exposed an overload of the VbaModuleCollection.remove method that can now accept an instance of Worksheet to remove all the VBA modules associated with the specified Worksheet.
  • Modified Cell.getFormatConditions method that now returns an array of type FormatConditionCollection.
  • Enhanced the PDF & image rendering engines to properly handle the long hyphens.
  • Provided support for WebQuery type of external data source.
  • Handled calculation problem while calculating formula based on Named Range.
  • Improved the chart rendering for PDF & image formats.

Aspose.Cells for Java Resources

The resources, you may need to accomplish your tasks: