使用C#移动到excel中下一行的下一个单元格 [英] Move to next cell in the next row in excel using c#
问题描述
如何使用C#移至Excel中的下一行.我正在使用Office PIA v14.当我使用Range.Next属性时,它将带我直接进入该范围的单元格.如何移动到下一行? IE.紧挨着下面的单元格.
How can I move to the next row in Excel using C#. I'm using Office PIA v 14. When I used Range.Next property, it takes me to the cell immediately right to the range. How can I move to the next row? ie. the cell immediately below.
推荐答案
Range.Next返回代表下一个单元格的Range对象.
Range.Next returns a Range object that represents the next cell.
我并不是真正的最出色的专家,但是根据文档,您应该改用Offset. http://msdn.microsoft.com/en -us/library/microsoft.office.interop.excel.range.offset
I'm not really the greatest expert alive but according to the documentation you should use Offset instead. http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.offset
这是一些伪代码
var excelApp = this.Application;
int skipRows = 1;
int skipCells = 0;
var nextRange = excelApp.ActiveCell.Offset[skipRows, skipCells].Select();
这篇关于使用C#移动到excel中下一行的下一个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!