如果对单元格有引用,是否可以在Excel工作表中四处走动?
像这样

Microsoft.Office.Interop.Excel.Range cellWalker = mfe.GetMyCell(Mysheet);

cellWalker = cellWalker.GoUpOneRowButKeepColumn();
cellWalker = cellWalker.GoDownOneRowButKeepColumn();
cellWalker = cellWalker.GoLeftOneColumnButKeepRow();
cellWalker = cellWalker.GoRightOneColumnButKeepRow();




问候斯特凡

最佳答案

Range.Offset属性将为您完成此操作。例如。

Microsoft.Office.Interop.Excel.Range cellWalker = mfe.GetMyCell(Mysheet);

cellWalker = cellWalker.Offset[-1, 0]; // GoUpOneRowButKeepColumn
cellWalker = cellWalker.Offset[1, 0];  // GoDownOneRowButKeepColumn
cellWalker = cellWalker.Offset[0, -1]; // GoLeftOneColumnButKeepRow
cellWalker = cellWalker.Offset[0, 1];  // GoRightOneColumnButKeepRow

10-08 19:57