公共 API Aspose.Cells 8.9.0 的变化

添加的 API

添加了 HtmlSaveOptions.DefaultFontName 属性

Aspose.Cells for Java 8.9.0 公开了 HtmlSaveOptions 类的 DefaultFontName 属性,允许在将电子表格呈现为 HTML 格式时指定默认字体名称。只有当样式字体不存在时,才会使用默认字体。 HtmlSaveOptions.DefaultFontName 属性的默认值为 null,即 Aspose.Cells for Java API 将使用与原始字体同族的通用字体。

以下是简单的使用场景。

Java

 //Create an instance of HtmlSaveOptions

HtmlSaveOptions options = new HtmlSaveOptions();

//Set default font name for Html rendering

options.setDefaultFontName("Arial");

//Load a spreadsheet in an instance of Workbook

Workbook book = new Workbook(dir + "sample.xlsx");

//Save the spreadsheet in Html format while passing instance of HtmlSaveOptions

book.save(dir + "output.html", options);

添加了 ImageOrPrintOptions.DefaultFont 属性

Aspose.Cells for Java 8.9.0 允许通过公开 DefaultFont 属性为 ImageOrPrintOptions 类设置默认字体名称。当电子表格中的 Unicode 字符未在单元格样式中设置正确的字体时,可以使用上述属性,因此此类字符可能在结果图像中显示为块。

以下是简单的使用场景。

Java

 //Create an instance of ImageOrPrintOptions

ImageOrPrintOptions options = new ImageOrPrintOptions();

//Set default font name for image rendering

options.setDefaultFont("Arial");

//Load a spreadsheet in an instance of Workbook

Workbook book = new Workbook(dir + "sample.xlsx");

//Access the worksheet to be rendered

Worksheet sheet = book.getWorksheets().get(0);

//Create an instance of SheetRender

SheetRender render = new SheetRender(sheet, options);

//Save spreadsheet to image

render.toImage(0, dir + "output.png");

添加了 PivotTable.Excel2003Compatible 属性

Aspose.Cells for Java API 公开了数据透视表类的布尔类型 Excel2003Compatible 属性,它允许指定数据透视表是否与 Excel 2003 兼容以用于刷新目的。 Excel2003Compatible 属性的默认值为true,即字符串必须小于或等于255 个字符。如果字符串大于 255 个字符,它将被截断。如为虚假,则不会受到上述限制。

以下是简单的使用场景。

Java

 //Load a spreadsheet in an instance of Workbook

Workbook book = new Workbook(dir + "sample.xlsx");

//Access the desired Pivot Table from the spreadsheet

PivotTable pivot = book.getWorksheets().get(0).getPivotTables().get(0);

//Set Excel 2003 compatibility to false

pivot.setExcel2003Compatible(false);

//Refresh & recalculate Pivot Table

pivot.refreshData();

pivot.calculateData();