1
我正在使用以下代碼嘗試進行收費並引發com異常。我正在試圖製作一張圖表。有沒有什麼明顯的我的代碼做錯了?錯誤發生在get_range行。正確使用get_range製作圖表
static void makechart(int counter, int startcount, Worksheet sourcesheet)
{
Range chartrange;
string rangestr = "G" + startcount.ToString() + ":G" + counter.ToString() + ",I" + startcount.ToString() + ":I" + counter.ToString();
ChartObjects xlcharts = (ChartObjects)sourcesheet.ChartObjects(Type.Missing);
ChartObject myChart = (ChartObject)xlcharts.Add(10, 80, 300, 250);
Chart chartPage = myChart.Chart;
chartrange = objsheet.get_Range(rangestr,Type.Missing);
//chartrange = sourcesheet.get_Range("G1", "B" + counter + 1);
chartPage.SetSourceData(chartrange, Type.Missing);
chartPage.ChartType = XlChartType.xlBarClustered;
}
objsheet ??定義在哪裏?你的意思是源代碼? – amuz
扔什麼異常? – MatthewD