0

我目前正在开发允许我在写入后从excel文件中读取的应用程序(在单元格A1中编写一个函数,从单元格A2生成一个表格,然后删除第一行),问题是每次我读取文件;第一列的标题包含此错误:

N\A: Impossible de lire la propriété Select de la classe Range. !!!

N \ A: Unable To Get The Find Property Of The Range Class !!!

这是代码:

var theWorksheet9 = (Microsoft.Office.Interop.Excel._Worksheet)theWorkbook.Worksheets.Item[10];
            theWorksheet9.Name = "MyFunctionName"; // rename the worksheet
            theWorksheet9.Activate();
            theWorksheet9.Range["A1"].Formula = MyFunction; //set the function
            theWorksheet9.Range["A1"].Calculate();  //execute the function
            theWorksheet9.Calculate();
            //Console.WriteLine(theWorksheet9.Range["A2"].Value2);
            theWorksheet9.Range["A1"].EntireRow.Delete(XlDeleteShiftDirection.xlShiftUp); // to delete the first row where the function was writed and executed
                //Console.WriteLine(theWorksheet9.Range["A1"].Value2);

当我尝试显示第一列的标题时:

Console.WriteLine(theWorksheet9.Range["A2"].Value);

它向我抛出了这个异常:

{"The call is ambiguous between the following methods or properties: 'System.Console.WriteLine(string)' and 'System.Console.WriteLine(char[])'"}
4

0 回答 0