值是一个变量,但用作方法

发布于 2024-07-26 12:49:48 字数 1218 浏览 4 评论 0原文

这里的错误是“范围是一个变量,但用作方法”

我添加了“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++;

}

它显示错误 - 值是一个变量,但用作方法。

请帮助我

谢谢拉姆

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-08-02 12:49:49

问题出在这一行上,

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 声明为二维对象数组,并且在第一行中您尝试使用它是一个方法,即 !value(CellRange).Locked

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文