I'm wondering if there is a simple property in the Excel interop that returns the count of used columns--ones containing data--from a given worksheet.
我想知道Excel互操作中是否有一个简单的属性,它返回给定工作表中使用过的列的数量 - 包含数据的列数。
In example: If myWorksheet.Columns.Count returns the total number of columns in a given worksheet, is there no equivalent along the lines of: myWorksheet.Columns.UsedCount?
例如:如果myWorksheet.Columns.Count返回给定工作表中的总列数,那么在以下行中是否没有等效的:myWorksheet.Columns.UsedCount?
I'm not sure if this question is too basic to even ask, but in searching google I can only seem to find rather arcane solutions to something that seems like a rather basic type of thing a person would want to do, when interacting with Excel.
我不确定这个问题是否太基本甚至无法提问,但在搜索谷歌时我似乎只能找到一些相当神秘的解决方案,这些解决方案似乎是一个人想要做的事情,当与Excel交互时。
I've tried to keep this brief by not posing up a bunch of unrelated code; but please let me know if I haven't been explicit enough.
我试图通过不构成一堆不相关的代码来保持这个简短;但如果我不够明确,请告诉我。
1 个解决方案
#1
3
Using the interop you can get the range of used elements using
使用互操作,您可以使用使用的元素范围
oXLSheet.UsedRange.Address
where oXLSheet is your Worksheet object
其中oXLSheet是您的Worksheet对象
#1
3
Using the interop you can get the range of used elements using
使用互操作,您可以使用使用的元素范围
oXLSheet.UsedRange.Address
where oXLSheet is your Worksheet object
其中oXLSheet是您的Worksheet对象