Read Chart Subtitle from ODS File with C++

Read Chart Subtitle from ODS File

Aspose.Cells provides you with the ability to read chart subtitles in ODS files by using the Chart.SubTitle property. The following sample code loads the sample ODS file and reads the chart subtitle using Chart.SubTitle property and prints it in the Console Window. Please see the console output of the code given below for reference.

Sample Code

#include <iostream>
#include "Aspose.Cells.h"

using namespace Aspose::Cells;
using namespace std;

int main()
{
    Aspose::Cells::Startup();

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Load excel file containing charts
    Workbook workbook(srcDir + u"SampleChart.ods");

    // Access first worksheet
    Worksheet worksheet = workbook.GetWorksheets().Get(0);

    // Access first chart inside the worksheet
    Chart chart = worksheet.GetCharts().Get(0);

    // Print chart subtitle
    cout << "Chart Subtitle: " << chart.GetSubTitle().GetText().ToUtf8() << endl;

    Aspose::Cells::Cleanup();
    return 0;
}

Console Output

Chart Subtitle: Sample Chart Subtitle