Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Excel工作表。单元格工作不正常_C#_Excel_Cells_Worksheet - Fatal编程技术网

C# Excel工作表。单元格工作不正常

C# Excel工作表。单元格工作不正常,c#,excel,cells,worksheet,C#,Excel,Cells,Worksheet,我正在使用Microsoft.Office.Interop.Excel对象用C编写代码。 这是我的代码: var lastCell = xlsSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell); xlRange = xlsSheet.Cells[lastCell.Row][lastCell.Column + 1] 在一种情况下: lastCell.Row=22和lastCell.Column=21,但xlRange.Row

我正在使用Microsoft.Office.Interop.Excel对象用C编写代码。 这是我的代码:

var lastCell = xlsSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell);
xlRange = xlsSheet.Cells[lastCell.Row][lastCell.Column + 1]
在一种情况下:

lastCell.Row=22和lastCell.Column=21,但xlRange.Row=22和xlRange.Column=23

或者在其他情况下

lastCell.Row=23和lastCell.Column=23,但xlRange.Row=24和xlRange.Column=23


出了什么问题?

Excel的行和列的索引从1到n,而不是从0到n作为数组或任何有序集合。这会导致混淆吗?

@jon在第一种情况下,它应该是:xlRange.Row=22和xlRange.Column=22,在第二种情况下:xlRange.Row=23和xlRange.Column=24