没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|行业资讯|编辑:吉炜炜|2025-01-14 10:03:47.650|阅读 14 次
概述:Aspose.Words for .NET 允许您以编程方式生成和嵌入图表。本文将介绍如何使用 C# 在 Word 文档中创建图表。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
Microsoft Word 中的图表使数据可视化变得简单而有效。它们将数字转换为视觉效果,帮助您的内容脱颖而出。您可以直接在 Word 中创建图表来说明趋势、比较等。从条形图、饼图、折线图和其他样式中进行选择,以满足您的需求。Microsoft Word 具有用于创建图表的内置工具。但是,Aspose.Words for .NET 允许您以编程方式生成和嵌入图表。本博客介绍如何使用 C# 在 Word 文档中创建图表。
Aspose.Words 是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。
Aspose API支持流行文件格式处理,并允许将各类文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。
使用 C# API 在 Word 文档中创建图表
我们将使用Aspose.Words for .NET在 Word 文档中创建不同类型的图表。这个功能强大的库允许您以编程方式创建、编辑和转换 Word 文件。其强大的 API 使图表创建和自定义变得简单。开发人员可以将动态数据可视化无缝集成到他们的文档工作流程中。它是生成带有交互式图表的报告或文档的优选工具。
要开始使用 Aspose.Words for .NET,请按照以下简单步骤操作:
1、下载Aspose.Words for .NET
2、使用以下命令通过包管理器安装它:
PM> Install-Package Aspose.Words
在 Word 中创建柱形图
柱形图非常适合比较不同类别的数据。您可以使用 Aspose.Words for .NET 在 Word 文档中轻松创建柱形图。请按以下步骤操作:
下面的代码片段演示了如何使用 C# 在 Word 文档中创建柱形图。
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 }); // Save the document doc.Save("column-chart.docx");
使用 C# 在 Word 文档中创建柱形图
使用 C# 在 Word 文档中创建散点图
散点图对于显示两个变量之间的关系很有用。要在 Word 文档中插入散点图,请按照前面的步骤操作。只需在InsertChart()方法中设置ChartType.Scatter即可。
下面的代码示例展示了如何使用 C# 在 Word 文档中创建散点图。
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 }); // Save the document doc.Save("scatter-chart.docx");
使用 C# 在 Word 文档中插入面积图
面积图突出显示随时间变化的幅度。要在 Word 文档中创建面积图,请按照上述步骤操作。只需在InsertChart()方法中设置ChartType.Area即可。
下面的代码示例展示了如何使用 C# 在 Word 文档中创建面积图。
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 }); // Save the document doc.Save("area-chart.docx");
使用 C# 在 Word 文档中插入面积图
使用 C# 在 Word 文档中插入气泡图
气泡图非常适合显示三维数据。按照前面的步骤在 Word 文档中创建气泡图。只需在InsertChart()方法中设置ChartType.Bubble即可。
下面的代码示例演示了如何使用 C# 在 Word 文档中创建气泡图。
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 }); // Save the document doc.Save("bubble-chart.docx");
使用 C# 在 Word 文档中插入气泡图
使用 C# 在 Word 文档中创建折线图
折线图可用于显示随时间变化的数据趋势。要在 Word 文档中创建折线图,请按照上述步骤操作。只需在InsertChart()方法中设置ChartType.Line即可。
下面的代码示例演示如何使用 C# 在 Word 文档中创建折线图。
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape shape = builder.InsertChart(ChartType.Line, 432, 252); Chart chart = shape.Chart; // Determines whether the title shall be shown for this chart. Default is true. chart.Title.Show = true; // Setting chart Title. chart.Title.Text = "Sample Line Chart Title"; // Determines whether other chart elements shall be allowed to overlap title. chart.Title.Overlay = false; // Please note if null or empty value is specified as title text, auto generated title will be shown. // Determines how legend shall be shown for this chart. chart.Legend.Position = LegendPosition.Left; chart.Legend.Overlay = true; // Save the document doc.Save("line-chart.docx");
使用 C# 在 Word 文档中插入折线图
结论
在本文中,我们介绍了如何使用 C# 在 Word 文档中创建不同类型的图表(柱形图、散点图、面积图和气泡图)。我们演示了如何使用 Aspose.Words for .NET 创建和自定义图表。按照这些步骤,您可以轻松地将视觉上吸引人的图表添加到 Word 文档中,从而增强数据分析和演示。
欢迎下载|体验更多Aspose产品
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@atlvshi.cn
文章转载自:慧都网Aspose.Words for Reporting Services 是独特的能在MS SQL Server Reporting Services中将RDL和RDLC报表导出为OOXML、DOC、RTF和WordprocessingML文档的解决方案。
Aspose.Words for JasperReports 可以帮助客户将报表从JasperReports 和 JasperServer 中导出为Microsoft Word document (DOC),Office Open XML (OOXML, DOCX),Rich Text Format (RTF),OpenDocument Text (ODT),Web page (HTML) 和纯text (TXT) 格式。
Aspose.Words for SharePoint是一个独特的解决方案,它支持文档转换,使在Microsoft SharePoint应用程序内转换和合并文档成为可能,并高度准确的支持多文档格式。
这篇文章介绍了IntelliJ IDEA的全新结构工具窗口,通过“逻辑视图”功能帮助开发者更清晰地理解应用程序结构,特别是在Spring Boot等框架中,展示了组件间的关联,提高了代码导航效率和开发生产力。
如果你还不太了解MES系统或者信息追溯的概念,别急,我这就用简单易懂的语言为大家详细讲解。
本文将为大家深入介绍QtitanDocking组件,看看它是如何为Qt应用程序提供灵活窗口解决方案的,欢迎下载最新版组件体验!
随着工业4.0的到来,测量行业正在向自动化和自动化方向发展。HOOPS作为一种强大的3D开发工具,凭借其精准的测量、可视化和自动化功能,正在为测量行业带来革命性的变革。
无需Microsoft Word也可在任何平台上满足Word文档的一切操作需求。
Aspose.Words for Reporting ServicesAspose.Words for Reporting Services 是独特的能在MS SQL Server Reporting Services中将RDL和RDLC报表导出为OOXML、DOC、RTF和WordprocessingML文档的解决方案。
Aspose.Words for JasperReportsAspose.Words for JasperReports 可以帮助客户将报表从JasperReports 和 JasperServer 中导出为Microsoft Word document (DOC),Office Open XML (OOXML, DOCX),Rich Text Format (RTF),OpenDocument Text (ODT),Web page (HTML) 和纯text (TXT) 格式。
Aspose.Words for SharePointAspose.Words for SharePoint是一个独特的解决方案,它支持文档转换,使在Microsoft SharePoint应用程序内转换和合并文档成为可能,并高度准确的支持多文档格式。
Aspose.Words for Android via Java从Android应用程序中生成,操作,转换和渲染Word文件,而不依赖于Microsoft Word。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@atlvshi.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢