如何使用C#代码在Excel中更改图表布局 [英] How to change chart Layout in Excel using C# code

查看:155
本文介绍了如何使用C#代码在Excel中更改图表布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何在Excel工作表中更改图表的布局.这是我的代码.

Hi,
How to change the Layout of chart in excel sheet. Here is my code.

Excel.Range chartRange;

                  Excel.ChartObjects xlCharts = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);
                  Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(225, max * 15, 300, 250);
                  Excel.Chart chartPage = myChart.Chart;
                  chartPage.ChartArea.Font.Name = "BankGothic Lt BT";
                  chartRange = xlWorkSheet.get_Range("K7", "L8");
                  chartPage.SetSourceData(chartRange, misValue);
                  chartPage.ChartType = Excel.XlChartType.xl3DPieExploded;




我输入为




I type as

myChart.ApplyLayout(10, myChart.ChartType); // But its not taken showing error.

推荐答案

ApplyLayout是正确的方法.参考: http://msdn.microsoft.com/zh-我们/library/microsoft.office.tools.excel.chart.applylayout.aspx [
ApplyLayout is the right method. Ref: http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.chart.applylayout.aspx[^]

Could you verify whether the assembly Microsoft.Office.Tools.Excel is referred properly via Microsoft.Office.Tools.Excel.dll


这篇关于如何使用C#代码在Excel中更改图表布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆