2017-09-16 16:34:45 +09:00
|
|
|
// chartsheet.cpp
|
|
|
|
|
2017-09-16 12:21:23 +09:00
|
|
|
#include <QtCore>
|
|
|
|
#include "xlsxdocument.h"
|
|
|
|
#include "xlsxchartsheet.h"
|
|
|
|
#include "xlsxcellrange.h"
|
|
|
|
#include "xlsxchart.h"
|
|
|
|
|
|
|
|
using namespace QXlsx;
|
|
|
|
|
2017-09-16 16:34:45 +09:00
|
|
|
int chartsheet()
|
2017-09-16 12:21:23 +09:00
|
|
|
{
|
|
|
|
//![0]
|
|
|
|
Document xlsx;
|
|
|
|
for (int i=1; i<10; ++i)
|
|
|
|
xlsx.write(i, 1, i*i);
|
|
|
|
//![0]
|
|
|
|
|
|
|
|
//![1]
|
|
|
|
xlsx.addSheet("Chart1", AbstractSheet::ST_ChartSheet);
|
|
|
|
Chartsheet *sheet = static_cast<Chartsheet*>(xlsx.currentSheet());
|
|
|
|
Chart *barChart = sheet->chart();
|
|
|
|
barChart->setChartType(Chart::CT_Bar);
|
|
|
|
barChart->addSeries(CellRange("A1:A9"), xlsx.sheet("Sheet1"));
|
|
|
|
//![1]
|
|
|
|
|
|
|
|
//![2]
|
2017-09-23 11:43:18 +09:00
|
|
|
xlsx.saveAs("chartsheet1.xlsx");
|
2017-09-16 12:21:23 +09:00
|
|
|
//![2]
|
|
|
|
|
2017-09-23 11:43:18 +09:00
|
|
|
Document xlsx2("chartsheet1.xlsx");
|
|
|
|
xlsx2.saveAs("chartsheet2.xlsx");
|
2017-09-24 00:09:33 +09:00
|
|
|
|
2017-09-16 12:21:23 +09:00
|
|
|
return 0;
|
|
|
|
}
|