0

The error here is "Range is a variable but used as a method"

I added " Microsoft.Office.Interop.Excel" and using it currently as

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++;

}

it shows the errror - value is a variable but used like a method..

please help me

Thanks

Ramm

Sam Saffron
  • 128,308
  • 78
  • 326
  • 506
user301016
  • 2,207
  • 7
  • 36
  • 50

1 Answers1

2

The problem is on this line

if (!value (excelworksheet.Cells[CurTaskNode.DATA_MIN_ROW + minRow, CurTaskNode.DATA_MIN_COL + minCol]).Locked)

Change it to:

if (value == null && !excelworksheet.Cells[CurTaskNode.DATA _MIN _ROW + minRow, CurTaskNode.DATA _MIN _COL + minCol]).Locked)

The error is being raised because you have declared value as a 2 dimensional object array and in the first line you are trying to use it is a method i.e. !value(CellRange).Locked

James
  • 80,725
  • 18
  • 167
  • 237
  • Error 1 Operator '!' cannot be applied to operand of type 'object' is displayed when used as suggested. Please help Thank u Ramm – user301016 Jul 02 '09 at 13:38
  • You need to explain what it is your trying to do a little more clearly for me to give a definitive answer. – James Jul 02 '09 at 14:01
  • The reason you will be getting the above error is because you are trying to assign a boolean operator against an object array. – James Jul 02 '09 at 14:02