我如何获得包含从Excel中的数据列的数 [英] how do i get a count of columns that contain data from excel

查看:96
本文介绍了我如何获得包含从Excel中的数据列的数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有一个在Excel的互操作,返回使用的列的计数一个简单的属性 - 那些包含数据 - 从给定的工作表

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.

在例如: 如果myWorksheet.Columns.Count返回给定的工作表列总数,有没有线沿线的不等价的:?myWorksheet.Columns.UsedCount

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?

我不知道,如果这个问题是太基本了,甚至问,但在谷歌搜索我只能似乎找到相当神秘的解决方案的东西,看起来像的事情,而基本型的人会想这样做,当与Excel交互。

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.

我试图通过不摆了一堆不相关的code保持这个简短的;但请让我知道如果我没有得到足够明确的。

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.

推荐答案

使用互操作,您可以使用习惯的元素范围

Using the interop you can get the range of used elements using

oXLSheet.UsedRange.Address

oXLSheet.UsedRange.Address

在这里oXLSheet是你的工作表对象

where oXLSheet is your Worksheet object

这篇关于我如何获得包含从Excel中的数据列的数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆