Aspose.Words For .Net是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。此外,API支持所有流行的Word处理文件格式,并允许将Word文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。

接下来我们将进入关于“使用图表”的介绍,在Aspose.Words中学会从头开始创建OOXML图表,包括柱状图、散点图、面积图和气泡图。


插入柱形图

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);// Add chart with default data. You can specify different chart types and sizes.
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);// Chart property of Shape contains all chart related options.
Chart chart = shape.Chart;// Get chart series collection.
ChartSeriesCollection seriesColl = chart.Series;
// Check series count.
Console.WriteLine(seriesColl.Count);// Delete default generated series.
seriesColl.Clear();// Create category names array, in this example we have two categories.
string[] categories = new string[] { "AW Category 1", "AW Category 2" };// Adding new series. Please note, data arrays must not be empty and arrays must be the same size.
seriesColl.Add("AW Series 1", categories, new double[] { 1, 2 });
seriesColl.Add("AW Series 2", categories, new double[] { 3, 4 });
seriesColl.Add("AW Series 3", categories, new double[] { 5, 6 });
seriesColl.Add("AW Series 4", categories, new double[] { 7, 8 });
seriesColl.Add("AW Series 5", categories, new double[] { 9, 10 });dataDir = dataDir + @"TestInsertSimpleChartColumn_out.doc";
doc.Save(dataDir);

该代码产生以下结果:

添加方法有四种不同的重载,可以覆盖所有图表类型的数据源的所有可能变体:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);// Insert Column chart.
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
Chart chart = shape.Chart;// Use this overload to add series to any type of Bar, Column, Line and Surface charts.
chart.Series.Add("AW Series 1", new string[] { "AW Category 1", "AW Category 2" }, new double[] { 1, 2 });dataDir = dataDir + @"TestInsertChartColumn_out.doc";
doc.Save(dataDir);

该代码产生以下结果:

插入散点图

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);// Insert Scatter chart.
Shape shape = builder.InsertChart(ChartType.Scatter, 432, 252);
Chart chart = shape.Chart;// Use this overload to add series to any type of Scatter charts.
chart.Series.Add("AW Series 1", new double[] { 0.7, 1.8, 2.6 }, new double[] { 2.7, 3.2, 0.8 });dataDir = dataDir + "TestInsertScatterChart_out.docx";
doc.Save(dataDir);

该代码产生以下结果:

插入面积图

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);// Insert Area chart.
Shape shape = builder.InsertChart(ChartType.Area, 432, 252);
Chart chart = shape.Chart;// Use this overload to add series to any type of Area, Radar and Stock charts.
chart.Series.Add("AW Series 1", new DateTime[] {
new DateTime(2002, 05, 01),
new DateTime(2002, 06, 01),
new DateTime(2002, 07, 01),
new DateTime(2002, 08, 01),
new DateTime(2002, 09, 01)}, new double[] { 32, 32, 28, 12, 15 });
dataDir = dataDir + @"TestInsertAreaChart_out.docx";
doc.Save(dataDir);

该代码产生以下结果:

插入气泡图

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithCharts();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);// Insert Bubble chart.
Shape shape = builder.InsertChart(ChartType.Bubble, 432, 252);
Chart chart = shape.Chart;// Use this overload to add series to any type of Bubble charts.
chart.Series.Add("AW Series 1", new double[] { 0.7, 1.8, 2.6 }, new double[] { 2.7, 3.2, 0.8 }, new double[] { 10, 4, 8 });
dataDir = dataDir + @"TestInsertBubbleChart_out.docx";
doc.Save(dataDir);

该代码产生以下结果:

Aspose.Words for .NET图表教程——创建四种OOXML图表相关推荐

  1. 后台CS代码中创建四种常用的SL动画效果

    http://www.cnblogs.com/chengxingliang/archive/2011/03/07/1974436.html后台CS代码中创建四种常用的动画效果[附带源码实例] 转载于: ...

  2. Executors类创建四种常见线程池

    文章目录 线程池架构 newSingleThreadExecutor newFixedThreadPool newCachedThreadPool newScheduledThreadPool Exe ...

  3. shell教程(二) 四种工作模式

    标准 根据 POSIX 标准,Shell 分为登录(login).非登录(non-login)和交互(interactive).非交互(non- interactive)两个维度的处理.因此 bash ...

  4. wps图表xy轴颠倒_还在嫌自己的图表丑?50+种可视化图表随你选

    随着大数据时代的奔涌而来,越来越多各行各业的从业人员开始重视数据的收集和分析. 不过接触过数据相关工作,或者有过一定了解的人都知道,原始数据一般都未经过加工和分析,呈现形态杂乱且无章可循. 于是,我们 ...

  5. excel 交互式图表_创建一个交互式Excel图表

    excel 交互式图表 If you add a chart to a dashboard, it's helpful to let people choose what they'd like to ...

  6. vsftp实用教程(四种配置需求)

    正文共: 1514字 11图 预计阅读时间: 5分钟 由于工作原因,需要在Linux服务器上搭建FTP服务,真相君选择使用vsftp这个工具,在搭建和使用过程中踩了一些坑,在这里分享给大家,希望大家能 ...

  7. 标题在图表上_Excel 2010基础应用:图表的创建与编辑

    在处理电子表格时,要对大量烦琐的数据进行分析和研究,有时需要利用图形方式再现数据变动和发展趋势.Excel提供了强有力的图表处理功能,使得用户很快就可得到所要的图表.下面介绍如何创建图表以及对图表的修 ...

  8. springcloud生产环境一般怎么部署_机器学习模型生产环境部署的四种系统架构总结...

    本文将从简单到复杂介绍典型架构的特点以及其优缺点. 介绍 一旦数据科学家对模型的性能感到满意,下一步便是"模型生产环境部署", 没有系统的合理配置,您的Kaggle Top1模型可 ...

  9. Electron教程(四)使用 Vue Browser 版,创建小工具应用

    Electron教程(四)使用 Vue Browser 版,创建小工具应用 Electron教程(一)什么是 Electron,由来.适用场景 和 Electron 的环境搭建 Electron教程( ...

最新文章

  1. 炎热的夏天过去了,老司机用Python带你爬爬哪个城市最热
  2. lvs工作在第几层_lvs负载均衡算法工作在哪一层
  3. Mysql 的 聚簇索引和二级索引
  4. QTcpServer / QTcpSocket 简单示例
  5. php怎样加速,php 提速
  6. U盘安装centos 7 提示 “Warning: /dev/root does not exist, could not boot” 解决办法
  7. 通过深度学习检测疟疾
  8. Triumph X发布著名摄影师Kim Joong-man首个NFT系列
  9. Avue表单select相关
  10. 黑苹果 惠普笔记本电池补丁_小米笔记本Pro 黑苹果 改装内置WIFI和蓝牙
  11. 2018-2019-1 20165318 20165322 20165326 实验二 固件程序设计
  12. 自助取号机应用-排队叫号机优势介绍
  13. 编程金融小白学 股票期权 lv.2 期权策略
  14. 如何求复数的模用计算机,Excel怎么计算复数? Excel对复数进行加减乘除指数对数模的教程...
  15. CSR蓝牙开发调试经验
  16. 关于给hexo博客增加视频vlog页面(主要引入哔哩哔哩视频)
  17. pix2pixHD:High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs
  18. jsp:关于ArrayList
  19. 西方经济学微观部分中的英文字母缩写
  20. WAF是干什么的 有哪些功能

热门文章

  1. mysql中自定义nvl函数
  2. CentOS7虚拟机安装
  3. 如果学习编程变成了修炼武功,你选择修炼哪一个?
  4. 归并排序和快速排序的浅析
  5. 深度模型(三):Capsule
  6. 简单说说我理解的图像的腐蚀和膨胀
  7. 在线图书API开放接口(永久免费开放)
  8. 哈夫曼树原理,及构造方法
  9. 世界最快固态硬盘CFD M2OPG1VN开卖:2500MB/s
  10. 计算代码时间复杂度方法