彩票走势图

Aspose.Words for C++使用教程:从Scratch创建OOXML图表(下)

翻译|使用教程|编辑:黄竹雯|2019-04-17 13:40:39.000|阅读 365 次

概述:Aspose.Words提供了InsertChart方法,该方法已添加到DocumentBuilder类中。那么,让我们看看如何使用 DocumentBuilder-> InsertChart 方法将简单的散点图、面积图和气泡图插入到文档中。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

Aspose.Words for C++不依赖Microsoft Word,可在任何C++应用程序中生成和操作Word格式文档。本文将与大家分享如何插入散点图、面积图和气泡图到文档中。

下载Aspose.Words for C++最新试用版

Aspose.Words for C++提供了 InsertChart 方法,该方法已添加到 DocumentBuilder 类中。那么,让我们看看如何使用 DocumentBuilder-> InsertChart 方法将简单的图表插入到文档中:

如何插入散点图

下面的示例显示了如何插入散点图。

// The path to the documents directory.
System::String dataDir = GetDataDir_WorkingWithCharts();
System::SharedPtr doc = System::MakeObject();
System::SharedPtr builder = System::MakeObject(doc);

// Insert Scatter chart.
System::SharedPtr shape = builder->InsertChart(ChartType::Scatter, 432, 252);
System::SharedPtr chart = shape->get_Chart();

// Use this overload to add series to any type of Scatter charts.
chart->get_Series()->Add(u"AW Series 1", System::MakeArray({0.7, 1.8, 2.6}), System::MakeArray({2.7, 3.2, 0.8}));

System::String outputPath = dataDir + GetOutputFilePath(u"InsertScatterChart.docx");
doc->Save(outputPath);

该代码产生以下结果:

ScatterChart

如何插入面积图。

下面的示例显示了如何插入散点图。

// The path to the documents directory.
System::String dataDir = GetDataDir_WorkingWithCharts();
System::SharedPtr doc = System::MakeObject();
System::SharedPtr builder = System::MakeObject(doc);

// Insert Area chart.
System::SharedPtr shape = builder->InsertChart(ChartType::Area, 432, 252);
System::SharedPtr chart = shape->get_Chart();

// Use this overload to add series to any type of Area, Radar and Stock charts.
chart->get_Series()->Add(u"AW Series 1",
                         System::MakeArray({System::DateTime(2002, 5, 1), System::DateTime(2002, 6, 1), System::DateTime(2002, 7, 1), System::DateTime(2002, 8, 1), System::DateTime(2002, 9, 1)}),
                         System::MakeArray({32, 32, 28, 12, 15}));
System::String outputPath = dataDir + GetOutputFilePath(u"InsertAreaChart.docx");
doc->Save(outputPath);

该代码产生以下结果:

Area Chart

如何插入气泡图。

下面的示例显示了如何插入气泡图。

// The path to the documents directory.
System::String dataDir = GetDataDir_WorkingWithCharts();
System::SharedPtr doc = System::MakeObject();
System::SharedPtr builder = System::MakeObject(doc);

// Insert Bubble chart.
System::SharedPtr shape = builder->InsertChart(ChartType::Bubble, 432, 252);
System::SharedPtr chart = shape->get_Chart();

// Use this overload to add series to any type of Bubble charts.
chart->get_Series()->Add(u"AW Series 1",
                         System::MakeArray({0.7, 1.8, 2.6}),
                         System::MakeArray({2.7, 3.2, 0.8}),
                         System::MakeArray({10, 4, 8}));
System::String outputPath = dataDir + GetOutputFilePath(u"InsertBubbleChart.docx");
doc->Save(outputPath);

该代码产生以下结果:

Bubble Chart

为你推荐:Aspose专题 - Aspose最新资源合集


想要购买正版授权,或者获取更多Aspose.Words for C++相关信息的朋友可以点击" "~

标签:文档管理wordAspose.words文档处理

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP