InsertChart

InsertChart(ChartType, double, double)

将图表对象插入文档并将其缩放到指定大小。

public Shape InsertChart(ChartType chartType, double width, double height)
范围类型描述
chartTypeChartType要插入到文档中的图表类型。
widthDouble图像的宽度(以磅为单位)。可以为负值或零,以请求 100% 缩放。
heightDouble图像的高度(以磅为单位)。可以为负值或零,以请求 100% 缩放。

返回值

刚刚插入的图像节点。

评论

您可以使用 更改图像大小、位置、定位方法和其他设置Shape此方法返回的对象。

例子

展示如何将饼图插入文档。

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Chart chart = builder.InsertChart(ChartType.Pie, ConvertUtil.PixelToPoint(300), 
    ConvertUtil.PixelToPoint(300)).Chart;
chart.Series.Clear();
chart.Series.Add("My fruit",
    new[] { "Apples", "Bananas", "Cherries" },
    new[] { 1.3, 2.2, 1.5 });

doc.Save(ArtifactsDir + "DocumentBuilder.InsertPieChart.docx");

也可以看看


InsertChart(ChartType, double, double, ChartStyle)

将图表对象插入文档并将其缩放到指定大小。

public Shape InsertChart(ChartType chartType, double width, double height, ChartStyle chartStyle)
范围类型描述
chartTypeChartType要插入到文档中的图表类型。
widthDouble图像的宽度(以磅为单位)。可以为负值或零,以请求 100% 缩放。
heightDouble图像的高度(以磅为单位)。可以为负值或零,以请求 100% 缩放。
chartStyleChartStyle插入图表的样式。

返回值

刚刚插入的图像节点。

评论

您可以使用 更改图像大小、位置、定位方法和其他设置Shape此方法返回的对象。

也可以看看


InsertChart(ChartTypeRelativeHorizontalPosition, double, RelativeVerticalPosition, double, double, double, WrapType)

将图表对象插入文档并将其缩放到指定大小。

public Shape InsertChart(ChartType chartType, RelativeHorizontalPosition horzPos, double left, 
    RelativeVerticalPosition vertPos, double top, double width, double height, WrapType wrapType)
范围类型描述
chartTypeChartType要插入到文档中的图表类型。
horzPosRelativeHorizontalPosition指定从哪里测量到图像的距离。
leftDouble从原点到图像左侧的距离(以点为单位)。
vertPosRelativeVerticalPosition指定从哪里测量到图像的距离。
topDouble从原点到图像顶部的距离(以点为单位)。
widthDouble图像的宽度(以磅为单位)。可以为负值或零,以请求 100% 缩放。
heightDouble图像的高度(以磅为单位)。可以为负值或零,以请求 100% 缩放。
wrapTypeWrapType指定如何让文本环绕图像。

返回值

刚刚插入的图像节点。

评论

您可以使用 更改图像大小、位置、定位方法和其他设置Shape此方法返回的对象。

例子

显示如何在插入图表时指定位置和换行。

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertChart(ChartType.Pie, RelativeHorizontalPosition.Margin, 100, RelativeVerticalPosition.Margin,
    100, 200, 100, WrapType.Square);

doc.Save(ArtifactsDir + "DocumentBuilder.InsertedChartRelativePosition.docx");

也可以看看


InsertChart(ChartTypeRelativeHorizontalPosition, double, RelativeVerticalPosition, double, double, double, WrapTypeChartStyle)

将图表对象插入文档并将其缩放到指定大小。

public Shape InsertChart(ChartType chartType, RelativeHorizontalPosition horzPos, double left, 
    RelativeVerticalPosition vertPos, double top, double width, double height, WrapType wrapType, 
    ChartStyle chartStyle)
范围类型描述
chartTypeChartType要插入到文档中的图表类型。
horzPosRelativeHorizontalPosition指定从哪里测量到图像的距离。
leftDouble从原点到图像左侧的距离(以点为单位)。
vertPosRelativeVerticalPosition指定从哪里测量到图像的距离。
topDouble从原点到图像顶部的距离(以点为单位)。
widthDouble图像的宽度(以磅为单位)。可以为负值或零,以请求 100% 缩放。
heightDouble图像的高度(以磅为单位)。可以为负值或零,以请求 100% 缩放。
wrapTypeWrapType指定如何让文本环绕图像。
chartStyleChartStyle插入图表的样式。

返回值

刚刚插入的图像节点。

评论

您可以使用 更改图像大小、位置、定位方法和其他设置Shape此方法返回的对象。

也可以看看