构建图表数据
/// 构建图表数据for (int i = 1; i < 10; ++i) {mxlsx.write(i, 1, i * i * i); // A1:A9mxlsx.write(i, 2, i * i); // B1:B9mxlsx.write(i, 3, i * i - 1); // C1:C9}
需要包含头文件
#include "xlsxchart.h"
1. 饼状图
Chart *pieChart = mxlsx.insertChart(3, 3, QSize(300, 300));pieChart->setChartType(Chart::CT_PieChart);pieChart->addSeries(CellRange("A1:A9"));pieChart->addSeries(CellRange("B1:B9"));pieChart->addSeries(CellRange("C1:C9"));
2. 饼状图(3D)
在WPS中显示存在问题
Chart *pie3DChart = mxlsx.insertChart(3, 9, QSize(300, 300));