Я столкнулся с небольшой проблемой.Я создал код, который создает лист Excel с несколькими записями и создает линейную диаграмму.Но проблема в том, что я не могу расположить график в указанной позиции.Вот мой код:
excelApp.ActiveSheet.Shapes.AddChart.Select();
excelApp.ActiveChart.ChartType = Excel.XlChartType.xlLine;
excelApp.ActiveChart.SetSourceData(Source: excelApp.Range["Sheet1!$A$1:$B$7"]);
excelApp.ActiveChart.Parent.Name = "mainChartView";
excelApp.ActiveChart.Shapes.Item(excelApp.ActiveChart.Name).Top = 100;
// or excelApp.ActiveChart.Shapes.Item("mainChartView").Top = 100;
Оба возвращают следующую ошибку:
ArgumentExecption was unhandled (The item with the specified name wasn't found).
Это строка ошибки:
excelApp.ActiveChart.Shapes.Item(excelApp.ActiveChart.Name).Top = 100;
// or excelApp.ActiveChart.Shapes.Item("mainChartView").Top = 100;
Я действительно надеюсь, что один изу вас есть правильный awnser, помощь очень ценится!
edit: Решение было:
excelApp.ActiveSheet.Shapes.Item("mainChartView").Top = 20;