3
您好,我有這個下面的代碼刪除/隱藏的傳說圖表Excel中
private static void exportChart()
{
Excel.Range chartRange;
Excel.ChartObjects xlCharts = (Excel.ChartObjects)oWorkSheet.ChartObjects(Type.Missing);
Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 150);
Excel.Chart chartPage = myChart.Chart;
chartRange = oWorkSheet.get_Range("E5", "F13");
chartPage.SetSourceData(chartRange, misValue);
chartPage.ChartType = Excel.XlChartType.xlColumnClustered;
Excel.Range chartPlacementRange = oWorkSheet.get_Range("F11", "F11");
myChart.Left = (float)((double)chartPlacementRange.Top);
myChart.Top = (float)((double)chartPlacementRange.Left);
}
我嘗試刪除圖表/隱藏的傳說,我已經從this鏈接
chart.Legend.LegendEnteries(chart.Legend.LegendEntries().Count).Delete();
所以在我的情況下,嘗試代碼它會是這樣的
chartPage.Legend.LegendEntries(chartPage.Legend.LegendEntries().Count).Delete();
但不幸的是,這是盡我所能......(後類型LegendEntries兩次是n ot available .count或.delete)
chartPage.Legend.LegendEntries(chartPage.Legend.LegendEntries());
如何正確地做到這一點?
更新我已經找到它...... 它實際上只用非常簡單的「chartPage.Legend.Clear();」 – Neversaysblack