Aspose::Cells::Charts::ChartDataTable class

ChartDataTable class

Represents a chart data table.

class ChartDataTable

Methods

MethodDescription
ChartDataTable(ChartDataTable_Impl* impl)Constructs from an implementation object.
ChartDataTable(const ChartDataTable& src)Copy constructor.
GetAutoScaleFont()True if the text in the object changes font size when the object size changes. The default value is True.
GetBackgroundMode()Gets and sets the display mode of the background.
GetBorder()Returns a Border object that represents the border of the object.
GetFont()Gets a Font object which represents the font setting of the specified chart data table.
GetHasBorderHorizontal()True if the chart data table has horizontal cell borders.
GetHasBorderOutline()True if the chart data table has outline borders.
GetHasBorderVertical()True if the chart data table has vertical cell borders.
GetShowLegendKey()True if the data label legend key is visible.
IsNull() constChecks whether the implementation object is nullptr.
explicit operator bool() constoperator bool()
operator=(const ChartDataTable& src)operator=
SetAutoScaleFont(bool value)True if the text in the object changes font size when the object size changes. The default value is True.
SetBackgroundMode(BackgroundMode value)Gets and sets the display mode of the background.
SetHasBorderHorizontal(bool value)True if the chart data table has horizontal cell borders.
SetHasBorderOutline(bool value)True if the chart data table has outline borders.
SetHasBorderVertical(bool value)True if the chart data table has vertical cell borders.
SetShowLegendKey(bool value)True if the data label legend key is visible.
~ChartDataTable()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
    //Instantiating a Workbook object
    Workbook workbook;

    //Obtaining the reference of the first worksheet
    Worksheet worksheet = workbook.GetWorksheets().Get(0);

    //Adding a sample value to "A1" cell
    worksheet.GetCells().Get(u"A1").PutValue(50);

    //Adding a sample value to "A2" cell
    worksheet.GetCells().Get(u"A2").PutValue(100);

    //Adding a sample value to "A3" cell
    worksheet.GetCells().Get(u"A3").PutValue(150);

    //Adding a sample value to "B1" cell
    worksheet.GetCells().Get(u"B1").PutValue(60);

    //Adding a sample value to "B2" cell
    worksheet.GetCells().Get(u"B2").PutValue(32);

    //Adding a sample value to "B3" cell
    worksheet.GetCells().Get(u"B3").PutValue(50);

    //Adding a chart to the worksheet
    int chartIndex = worksheet.GetCharts().Add(ChartType::Column, 5, 0, 25, 10);

    //Accessing the instance of the newly added chart
    Chart chart = worksheet.GetCharts().Get(chartIndex);

    //Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
    chart.GetNSeries().Add(u"A1:B3", true);

    chart.SetShowDataTable(true);

    //Getting Chart Table
    ChartDataTable chartTable = chart.GetChartDataTable();

    //Setting Chart Table Font Color
    chartTable.GetFont().SetColor(Color{ 0xff, 0xff, 0, 0 });

    //Setting Legend Key VisibilityOptions
    chartTable.SetShowLegendKey(false);

    //Saving the Excel file
    workbook.Save(u"book1.xls");

Aspose::Cells::Cleanup();

See Also