Aspose.Word for Net Word模板使用书签实现插入图表
一:创建模板
二:图表Docment构建
public Document chart() { var doc = new Document(); var builder = new DocumentBuilder(doc); var shape = builder.InsertChart(Aspose.Words.Drawing.Charts.ChartType.Column, 432, 252); var chart = shape.Chart; var seriescoll = chart.Series; seriescoll.Clear(); //Create category names array, in this example we have two categories. //创建类别名称数组,在此示例中我们有两个类别。 string[] categories = { "第一赛季", "第二赛季", "第三赛季" }; //添加新系列。数据数组不能为空,并且数组的大小必须相同。 seriescoll.Add("AW Series 1", categories, new double[] { 1, 2, 2 }); seriescoll.Add("AW Series 2", categories, new double[] { 3, 4, 44 }); seriescoll.Add("AW Series 3", categories, new double[] { 5, 6, 22 }); seriescoll.Add("AW Series 4", categories, new double[] { 7, 81, 3 }); seriescoll.Add("AW Series 5", categories, new double[] { 9, 10, 44 }); return doc; }
三:使用
Document doc = new Document(Server.MapPath(path)); builder.InsertDocument(chart(),ImportFormatMode.UseDestinationStyles); doc.Save(System.Web.HttpContext.Current.Response, "C00.doc", ContentDisposition.Attachment, null);
效果: