Skip to content

Commit

Permalink
[Excel Analyzer] handle chartsheets
Browse files Browse the repository at this point in the history
Don't error and dump internal structure of RubyXL gem parsing into the
metadata field
  • Loading branch information
gbp committed Jan 22, 2024
1 parent 089c34a commit f87ec29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gems/excel_analyzer/lib/excel_analyzer/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def external_links

def hidden_columns
workbook.worksheets.sum do |sheet|
next 0 unless sheet.is_a?(RubyXL::Worksheet)

hidden_columns = []

sheet.cols.compact.select(&:hidden).each do |col_range|
Expand All @@ -55,6 +57,8 @@ def hidden_columns

def hidden_rows
workbook.worksheets.sum do |sheet|
next 0 unless sheet.is_a?(RubyXL::Worksheet)

hidden_rows = sheet.sheet_data.rows.compact.select(&:hidden)

hidden_rows.count do |row|
Expand Down
13 changes: 13 additions & 0 deletions gems/excel_analyzer/spec/excel_analyzer/probe_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require "spec_helper"

RSpec.describe ExcelAnalyzer::Probe do
include ExcelAnalyzer::Probe

it "does not error if workbook has chartsheets" do
xlsx = File.open(File.join(__dir__, "../fixtures/chartsheet.xlsx"))
expect(probe(xlsx)).to be_a(Hash)
end
end

Check warning on line 13 in gems/excel_analyzer/spec/excel_analyzer/probe_spec.rb

View workflow job for this annotation

GitHub Actions / build

[rubocop] reported by reviewdog 🐶 1 trailing blank lines detected. (https://rubystyle.guide#newline-eof) Raw Output: gems/excel_analyzer/spec/excel_analyzer/probe_spec.rb:13:1: C: Layout/TrailingEmptyLines: 1 trailing blank lines detected. (https://rubystyle.guide#newline-eof)
Binary file added gems/excel_analyzer/spec/fixtures/chartsheet.xlsx
Binary file not shown.

0 comments on commit f87ec29

Please sign in to comment.