Read and Manipulate Excel 2016 Charts with Node.js via C++

Possible Usage Scenarios

Aspose.Cells now supports the reading and manipulation of Microsoft Excel 2016 charts, which are not present in Microsoft Excel 2013 or earlier versions.

Read and Manipulate Excel 2016 Charts

The following sample code loads the source Excel file which contains Excel 2016 charts in the first worksheet. It reads all charts one by one and changes their titles according to their chart types. The following screenshot shows the source Excel file before the execution of the code. As you can see, the chart title is the same for all charts.

todo:image_alt_text

The following screenshot shows the output Excel file after the execution of the code. As you can see, the chart titles are changed according to their chart types.

todo:image_alt_text

Sample Code

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "excel2016Charts.xlsx");

// Load source Excel file containing Excel 2016 charts
const workbook = new AsposeCells.Workbook(filePath);

// Access the first worksheet which contains the charts
const sheet = workbook.getWorksheets().get(0);

// Access all charts one by one and read their types
for (let i = 0; i < sheet.getCharts().getCount(); i++) {
    // Access the chart
    const ch = sheet.getCharts().get(i);

    // Print chart type
    console.log(ch.getType());

    // Change the title of the chart according to its type
    ch.getTitle().setText("Chart Type is " + ch.getType().toString());
}

// Save the workbook
workbook.save(path.join(dataDir, "out_excel2016Charts.xlsx"));

Console Output

Here is the console output of the above sample code when executed with the provided source Excel file.

  
Waterfall  
Treemap  
Sunburst  
Histogram  
BoxWhisker  

Advanced Topics