Public API Changes in Aspose.Cells 8.3.1

Added APIs

Added DataLabels.ShowCellRange Property

The getter/setter for the property ShowCellRange has been added to the DataLabels class in order to mimic Excel’s functionality of formatting a chart’s data labels at run‑time. Please note, Excel provides this feature through the following steps.

  1. Select Data Labels of the series and right‑click to open the pop‑up menu.
  2. Click Format Data Labels… and it will show Label Options.
  3. Check or un‑check the check box Label Contains – Value From Cells.

The sample code below accesses the data labels of the chart series and then sets the DataLabels.setShowCellRange() method to true to mimic Excel’s Label Contains – Value From Cells feature.

Java

 //Create workbook from the source spreadsheet containing an existing chart

Workbook workbook = new Workbook("sample.xlsx");

//Access the first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);

//Access the chart inside the worksheet

Chart chart = worksheet.getCharts().get(0);

//Check the "Label Contains - Value From Cells"

DataLabels dataLabels = chart.getNSeries().get(0).getDataLabels();

dataLabels.setShowCellRange(true);

//Save the workbook

workbook.save("output.xlsx");

Added Cell.getTable & ListObject.putCellValue Methods

The methods Cell.getTable and ListObject.putCellValue have been added with Aspose.Cells for Java 8.3.1 in order to facilitate users in accessing the ListObject from a cell and adding values inside it using row and column offsets. The following sample code loads the source spreadsheet and adds values inside the table.

Java

 //Create workbook from source Excel file

Workbook workbook = new Workbook("source.xlsx");

//Access first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);

//Access cell D5 which lies inside the table

Cell cell = worksheet.getCells().get("D5");

//Put value inside the cell D5

cell.putValue("D5 Data");

//Access the Table from this cell

ListObject table = cell.getTable();

//Add some value using row and column offset

table.putCellValue(2, 2, "Offset [2,2]");

//Save the workbook

workbook.save("output.xlsx");

Added OdsSaveOptions.isStrictSchema11 & OdsSaveOptions.setStrictSchema11 Methods

The methods isStrictSchema11 and setStrictSchema11 have been added to the OdsSaveOptions class in order to allow developers to save the spreadsheet in a format conforming to the ODF v1.2 specification. The default value of the setStrictSchema11 property is false, which means that from version 8.3.1 of Aspose.Cells APIs, ODS files will be saved as ODF format version 1.2 by default.

The code snippet below saves the ODS file in ODF 1.2 format.

Java

 //Create workbook

Workbook workbook = new Workbook();

//Access first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);

//Put some value in cell A1

Cell cell = worksheet.getCells().get("A1");

cell.putValue("Welcome to Aspose!");

//Save ODS in ODF 1.2 version (default)

OdsSaveOptions options = new OdsSaveOptions();

workbook.save("ODF1.2.ods", options);

//Save ODS in ODF 1.1 version

options.setStrictSchema11(true);

workbook.save("ODF1.1.ods", options);

Added SparklineCollection.add Method

Aspose.Cells APIs have exposed the SparklineCollection.add(String dataRange, int row, int column) method to specify the data range and location of a Sparkline group. Please note, Excel provides the same feature through the following steps.

  1. Select the cell containing your Sparkline.
  2. In the Design tab, select Edit Data from the Sparkline.
  3. Choose Edit Group Location & Data.
  4. Specify Data Range and Location.

The following sample code loads the source spreadsheet, accesses the first Sparkline group, and adds new data ranges and locations for the group.

Java

 //Create workbook from source Excel file

Workbook workbook = new Workbook("source.xlsx");

//Access first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);

//Access the first sparkline group

SparklineGroup group = worksheet.getSparklineGroupCollection().get(0);

//Add data ranges and locations inside this sparkline group

group.getSparklineCollection().add("D5:O5", 4, 15);
group.getSparklineCollection().add("D6:O6", 5, 15);
group.getSparklineCollection().add("D7:O7", 6, 15);
group.getSparklineCollection().add("D8:O8", 7, 15);

//Save the workbook

workbook.save("output.xlsx");