这里的错误是“Range是一个变量,但用作方法”
我添加了“Microsoft.Office.Interop.Excel”并将其当前用作
Microsoft.Office.Interop.Excel.Workbook SelWorkBook = excelappln1.Workbooks.Open(curfile, 0, false, 5, "", "", false,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true,
false, 0, false, false, false);
Microsoft.Office.Interop.Excel.Sheets excelSheets = SelWorkBook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet excelworksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(CurSheetName);
Microsoft.Office.Interop.Excel.Range excelRange = excelworksheet.UsedRange;
object[,] value;
excelRange = excelworksheet.get_Range(CurTaskNode.DATA_MIN_ROW, CurTaskNode.DATA_MIN_COL);
value = (object[,])excelRange.Cells.Value2;
and using the Value to check the cell is locked or not....
if (!value (excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol]).Locked)
{
// Assigning the Value from reader to the particular cell in excel sheet
excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol] = values[iValueIndex];
iValueIndex++;
}
它显示了errror - 值是一个变量但是像方法一样使用..
请帮帮我
谢谢
拉姆
答案 0 :(得分:2)
问题在于这一行
if (!value (excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol]).Locked)
将其更改为:
if (value == null && !excelworksheet.Cells[CurTaskNode.DATA _MIN _ROW + minRow, CurTaskNode.DATA _MIN _COL + minCol]).Locked)
引发错误是因为您已将值声明为二维对象数组,并且在您尝试使用它的第一行中是一个方法,即!value(CellRange).Locked