开发者

How do I create an Excel range object that refers to a name in Excel (c#)

开发者 https://www.devze.com 2023-01-10 08:43 出处:网络
I have an excel worksheet with various names and I want to create an object that references that name. The code I am working with uses the cell address, but that is very开发者_Python百科 cumbersome, a

I have an excel worksheet with various names and I want to create an object that references that name. The code I am working with uses the cell address, but that is very开发者_Python百科 cumbersome, and I would rather use the names.

My code looks like this right now:

myWorksheet= GetWorkSheet(myWorkbook);
Excel.Range range = myWorksheet.get_Range(cell1, cell2);

Instead of using cell1 and cell2, I would like to use the name that is in Excel already that describes the range.

Thanks for your help.


Simply do:

Excel.Range range = myWorksheet.get_Range("MyName", Type.Missing);
0

精彩评论

暂无评论...
验证码 换一张
取 消