class Xlsxrb::Ooxml::Reader::SheetViewListener
SAX2 listener for parsing <sheetViews><sheetView>, <pane>, and <selection>.
Attributes
Public Class Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 3593 def initialize @view = {} @pane = nil @selection = nil @inside_sheet_views = false end
Public Instance Methods
# File lib/xlsxrb/ooxml/reader.rb, line 3684 def end_element(_uri, local_name, qname) name = element_name(local_name, qname) @inside_sheet_views = false if name == "sheetViews" end
# File lib/xlsxrb/ooxml/reader.rb, line 3600 def start_element(_uri, local_name, qname, attributes) name = element_name(local_name, qname) case name when "sheetViews" @inside_sheet_views = true when "sheetView" return unless @inside_sheet_views wp = attributes["windowProtection"] @view[:window_protection] = %w[1 true].include?(wp) unless wp.nil? sf = attributes["showFormulas"] @view[:show_formulas] = %w[1 true].include?(sf) unless sf.nil? sgl = attributes["showGridLines"] @view[:show_grid_lines] = %w[1 true].include?(sgl) unless sgl.nil? srch = attributes["showRowColHeaders"] @view[:show_row_col_headers] = %w[1 true].include?(srch) unless srch.nil? szv = attributes["showZeros"] @view[:show_zeros] = %w[1 true].include?(szv) unless szv.nil? rtl = attributes["rightToLeft"] @view[:right_to_left] = %w[1 true].include?(rtl) unless rtl.nil? ts = attributes["tabSelected"] @view[:tab_selected] = true if ts == "1" srr = attributes["showRuler"] @view[:show_ruler] = %w[1 true].include?(srr) unless srr.nil? soss = attributes["showOutlineSymbols"] @view[:show_outline_symbols] = %w[1 true].include?(soss) unless soss.nil? dgc = attributes["defaultGridColor"] @view[:default_grid_color] = %w[1 true].include?(dgc) unless dgc.nil? sws = attributes["showWhiteSpace"] @view[:show_white_space] = %w[1 true].include?(sws) unless sws.nil? vm = attributes["view"] @view[:view] = vm if vm tlc = attributes["topLeftCell"] @view[:top_left_cell] = tlc if tlc cid = attributes["colorId"] @view[:color_id] = cid.to_i if cid zs = attributes["zoomScale"] @view[:zoom_scale] = zs.to_i if zs zsn = attributes["zoomScaleNormal"] @view[:zoom_scale_normal] = zsn.to_i if zsn zssl = attributes["zoomScaleSheetLayoutView"] @view[:zoom_scale_sheet_layout_view] = zssl.to_i if zssl zspl = attributes["zoomScalePageLayoutView"] @view[:zoom_scale_page_layout_view] = zspl.to_i if zspl when "pane" return unless @inside_sheet_views ys = attributes["ySplit"] xs = attributes["xSplit"] frozen = attributes["state"] == "frozen" tlc = attributes["topLeftCell"] ap = attributes["activePane"] p = if frozen { row: ys ? ys.to_i : 0, col: xs ? xs.to_i : 0, state: :frozen } else { row: ys ? ys.to_i : 0, col: xs ? xs.to_i : 0, x_split: xs ? xs.to_i : 0, y_split: ys ? ys.to_i : 0, top_left_cell: tlc, state: :split } end p[:active_pane] = ap if ap @pane = p when "selection" return unless @inside_sheet_views ac = attributes["activeCell"] sq = attributes["sqref"] sel = { active_cell: ac, sqref: sq } pn = attributes["pane"] sel[:pane] = pn if pn acid = attributes["activeCellId"] sel[:active_cell_id] = acid.to_i if acid @selection = sel if ac || sq || pn || acid end end