小编zai*_*men的帖子

以编程方式设置 Excel 图表标题

如何使用 C# 和 Interop 设置图表标题?

实际尝试:

            Excel.Range chartRange;

            Excel.ChartObjects xlCharts = (Excel.ChartObjects)xlsSheet.ChartObjects(Type.Missing);
            Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 250);
            Excel.Chart chartPage = myChart.Chart;

            chartRange = xlsSheet.Range[xlsSheet.Cells[1, 1], xlsSheet.Cells[ar.GetLength(0), ar.GetLength(1)]];
            chartPage.SetSourceData(chartRange, Excel.XlRowCol.xlRows);
            chartPage.ChartType = Excel.XlChartType.xl3DColumn;
            chartPage.Location(Excel.XlChartLocation.xlLocationAsNewSheet, oOpt);

            chartPage.HasTitle = true;
            chartPage.ChartTitle.Text = "HeaderText";
Run Code Online (Sandbox Code Playgroud)

给予甜蜜

“System.Runtime.InteropServices.COMException”

调用 COM 组件时返回了错误 HRESULT E_FAIL

c# com excel charts interop

6
推荐指数
1
解决办法
5124
查看次数

标签 统计

c# ×1

charts ×1

com ×1

excel ×1

interop ×1