views:

178

answers:

1

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.

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?

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.

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  A: 

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

oXLSheet.UsedRange.Address

where oXLSheet is your Worksheet object

Mitchel Sellers
I couldn't find 'Address'. but, you put me on the right path, kind sir.int usedCount = wsWorkOrders.UsedRange.Columns.Count; Worked like a charm. Thank you, greatly.
agentlame