C# Excel工作表。单元格工作不正常
我正在使用Microsoft.Office.Interop.Excel对象用C编写代码。 这是我的代码: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
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