views:

207

answers:

1

Hi,

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

+2  A: 

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
Error 1 Operator '!' cannot be applied to operand of type 'object' is displayed when used as suggested.Please helpThank uRamm
Aditya
You need to explain what it is your trying to do a little more clearly for me to give a definitive answer.
James
The reason you will be getting the above error is because you are trying to assign a boolean operator against an object array.
James