lib/write_xlsx/worksheet.rb in write_xlsx-0.97.0 vs lib/write_xlsx/worksheet.rb in write_xlsx-0.99.0

- old
+ new

@@ -310,18 +310,19 @@ @palette = workbook.palette @default_url_format = workbook.default_url_format @page_setup = PageSetup.new - @screen_gridlines = true - @show_zeros = true - @dim_rowmin = nil - @dim_rowmax = nil - @dim_colmin = nil - @dim_colmax = nil - @selections = [] - @panes = [] + @screen_gridlines = true + @show_zeros = true + @dim_rowmin = nil + @dim_rowmax = nil + @dim_colmin = nil + @dim_colmax = nil + @selections = [] + @panes = [] + @hide_row_col_headers = 0 @tab_color = 0 @set_cols = {} @set_rows = {} @@ -5343,10 +5344,17 @@ # @print_headers = 0 # end end # + # Set the option to hide the row and column headers in Excel. + # + def hide_row_col_headers + @hide_row_col_headers = 1 + end + + # # The fit_to_pages() method is used to fit the printed area to a specific # number of pages both vertically and horizontally. If the printed area # exceeds the specified number of pages it will be scaled down to fit. # This guarantees that the printed area will always appear on the # specified number of pages even if the page size or margins change. @@ -6755,13 +6763,16 @@ @writer.tag_elements('sheetViews', []) { write_sheet_view } end def write_sheet_view #:nodoc: attributes = [] - # Hide screen gridlines if required + # Hide screen gridlines if required. attributes << ['showGridLines', 0] unless @screen_gridlines + # Hide the row/column headers. + attributes << ['showRowColHeaders', 0] if ptrue?(@hide_row_col_headers) + # Hide zeroes in cells. attributes << ['showZeros', 0] unless show_zeros? # Display worksheet right to left for Hebrew, Arabic and others. attributes << ['rightToLeft', 1] if @right_to_left @@ -7292,16 +7303,23 @@ # # Write the <filters> element. # def write_filters(*filters) #:nodoc: - if filters.size == 1 && filters[0] == 'blanks' + non_blanks = filters.reject { |filter| filter =~ /^blanks$/i } + attributes = [] + + if filters != non_blanks + attributes = [ ['blank', 1] ] + end + + if filters.size == 1 && non_blanks.empty? # Special case for blank cells only. - @writer.empty_tag('filters', [ ['blank', 1] ]) + @writer.empty_tag('filters', attributes) else # General case. - @writer.tag_elements('filters') do - filters.each { |filter| write_filter(filter) } + @writer.tag_elements('filters', attributes) do + non_blanks.sort.each { |filter| write_filter(filter) } end end end #