Programmatically getting the last filled excel row using C#

前端 未结 10 920
执念已碎
执念已碎 2020-11-27 16:52

I am trying to get the last row of an excel sheet programatically using the Microsoft.interop.Excel Library and C#. I want to do that, because I am charged with looping thr

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 17:48

    For questions involving the Excel object model, it's often easier to try it out in VBA first, then translating to C# is fairly trivial.

    In this case one way to do it in VBA is:

    Worksheet.UsedRange.Row + Worksheet.UsedRange.Rows.Count - 1
    

提交回复
热议问题