Skip to content

Commit

Permalink
Welp, an adventure for another day
Browse files Browse the repository at this point in the history
  • Loading branch information
numist committed Nov 3, 2024
1 parent f68d6ce commit 39e54a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _plugins/csv_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def evaluate_formula_at_index_internal(col_index, row_index, table_data, visitin
end
end

evaluated_result = @calculator.evaluate(formula_with_values) or raise "Error: #{col_index_to_val(col_index)}#{row_index_to_val(row_index)} uses invalid formula: #{formula}"
evaluated_result = @calculator.evaluate(formula_with_values) or raise "Error: #{col_index_to_val(col_index)}#{row_index_to_val(row_index)} uses invalid formula: #{formula_with_values}"

@evaluation_cache[cell_key] = evaluated_result
evaluated_result
Expand Down
9 changes: 9 additions & 0 deletions _spec/csv_block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ def render_csv_block(content, tag_options = "")
expect(output).to include('<td>250</td>')
end

it 'understands currency?' do
csv_content = "$100\n$150\n=SUM(A1:A2)"
output = render_csv_block(csv_content, "header:false")

# Alas, for now.
# expect(output).to include('<td>$250</td>')
expect(output).to include('<td>Error: A3 uses invalid formula: SUM($100,$150)</td>')
end

it 'evaluates formulas with rectangular references' do
csv_content = "1, 10, =SUM(A1:B1)\n100, 1000, =SUM(A2:B2)\n=SUM(A1:A2), =SUM(B1:B2), =SUM(A1:B2)"
output = render_csv_block(csv_content, "header:false")
Expand Down

0 comments on commit 39e54a7

Please sign in to comment.