C#中的Excel.Range到String的转换 [英] Excel.Range to String conversion in C#
本文介绍了C#中的Excel.Range到String的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用.NET的Office互操作库,有人知道在字符串(例如"A57","$ L $ 2:$ M:$ 3")和类型为Excel.Range的相应对象之间来回转换的最佳方法吗?/p>
如果它也适用于命名范围",则奖励积分.
解决方案
使用 Worksheet
对象的 Range
属性,并传递 Type.Missing
作为第二个参数.
例如:
范围范围= sheet.get_Range("$ L $ 2:$ M:$ 3",Type.Missing);
这也支持命名范围.
Using .NET's Office interop libraries, does anybody know the best way to convert back and forth between strings (eg "A57", "$L$2:$M:$3") and corresponding objects of type Excel.Range?
Bonus points if it also works with "named ranges".
解决方案
Use the Range
property of a Worksheet
object, and pass Type.Missing
as the second parameter.
For example:
Range range = sheet.get_Range("$L$2:$M:$3", Type.Missing);
This also supports named ranges.
这篇关于C#中的Excel.Range到String的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文