From 054de56d12e203a5f0696f98ac9fad3159e7abc1 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sat, 15 Dec 2012 10:39:37 +0900 Subject: Added methods to simplify outlining with specs worksheet#outline_rows worksheet#outline_columns --- lib/axlsx/workbook/worksheet/pivot_table.rb | 3 +++ lib/axlsx/workbook/worksheet/worksheet.rb | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'lib') diff --git a/lib/axlsx/workbook/worksheet/pivot_table.rb b/lib/axlsx/workbook/worksheet/pivot_table.rb index d876f777..515f5d09 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table.rb @@ -135,6 +135,9 @@ module Axlsx # identifies the index of an object withing the collections used in generating relationships for the worksheet # @param [Any] object the object to search for # @return [Integer] The index of the object + # + # RM: I cannot find any place in the code base where this is actually used + # TODO: confirm with author before removal def relationships_index_of(object) objects = [cache_definition] objects.index(object) diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 62d4e557..b6dc7c38 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -608,9 +608,25 @@ module Axlsx @styles ||= self.workbook.styles end + def outline_rows(start_index, end_index, level = 1, collapsed = true) + outline rows, (start_index..end_index), level, collapsed + end + + def outline_columns(start_index, end_index, level = 1, collapsed = true) + outline column_info, (start_index..end_index), level, collapsed + end private + def outline(collection, range, level = 1, collapsed = true) + range.each do |index| + unless (item = collection[index]).nil? + item.outline_level = level + item.hidden = collapsed + end + sheet_view.show_outline_symbols = true + end + end def validate_sheet_name(name) DataTypeValidator.validate "Worksheet.name", String, name raise ArgumentError, (ERR_SHEET_NAME_TOO_LONG % name) if name.size > 31 -- cgit v1.2.3