0

I am parsing an Excel workbook using RubyXL and discovered that workbook[0] returns the first worksheet regardless of whether it is hidden.

I would like to isolate the first visible worksheet by coding something like workbook[0].not_hidden.

How can this be done in RubyXL?

sscirrus
  • 55,407
  • 41
  • 135
  • 228

1 Answers1

0

It turns out visibility is held in a parameter called @state, where a visible worksheet has @state = nil and a hidden worksheet has @state = 'hidden'.

So, to isolate the first visible worksheet:

worksheet = workbook.select{ |w| w.state.blank? }[0]

Or, to isolate the first hidden worksheet:

worksheet = workbook.select{ |w| w.state == 'hidden' }[0]
sscirrus
  • 55,407
  • 41
  • 135
  • 228