你好,我在示例中看到了word for .Net有个组合图表的示例,但是我没有找到实现的代码。
请问是哪个示例可以输出这种组合图表呢?
@zou_yw 本文件使用以下示例:
Document doc = new Document(MyDir + "Combo chart.docx");
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
Chart chart = shape.Chart;
ChartSeriesGroupCollection seriesGroups = chart.SeriesGroups;
// Find secondary axis and remove from the collection.
for (int i = 0; i < seriesGroups.Count; i++)
if (seriesGroups[i].AxisGroup == AxisGroup.Secondary)
seriesGroups.RemoveAt(i);
放置在 "数据 "文件夹中的文件用于检查某些功能,是手动创建的。
如果您需要创建类似的 “Aspose.Words”,可以使用
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.InsertChart(ChartType.Column, 450, 250);
Chart chart = shape.Chart;
ChartSeriesCollection series = chart.Series;
// Delete default generated series.
series.Clear();
string[] categories = new string[] { "Category 1", "Category 2", "Category 3", "Category 4" };
series.Add("Series 1", categories, new double[] { 2, 3, 4, 5});
series.Add("Series 2", categories, new double[] { 5, 2, 3, 5 });
// Create an additional series group, also of the line type.
ChartSeriesGroup newSeriesGroup = chart.SeriesGroups.Add(ChartSeriesType.Line);
// Specify the use of secondary axes for the new series group.
newSeriesGroup.AxisGroup = AxisGroup.Secondary;
// Hide the secondary X axis.
newSeriesGroup.AxisX.Hidden = true;
// Define title of the secondary Y axis.
newSeriesGroup.AxisY.Title.Show = true;
newSeriesGroup.AxisY.Title.Text = "Secondary Y axis";
Assert.AreEqual(ChartSeriesType.Line, newSeriesGroup.SeriesType);
// Add a series to the new series group.
ChartSeries series3 =
newSeriesGroup.Series.Add("Series 3", categories, new double[] { 13, 11, 16, 9 });
series3.Format.Stroke.Weight = 3.5;
doc.Save(ArtifactsDir + "Charts.SecondaryAxis.docx");
您可以在 此处 找到类似的示例。