Reputation: 63
In axlsx ruby gem making graph on a result of a pivot table is ending in error:
ArgumentError (Missing cell B228
for the specified range B228:B233
)
This makes me think that pivot table data is not really created until it is opened in LO or Excel. Is it possible to mitigate the error and put graph data on the sheet?
n_row = 223 # row number that program ended preparing data
# create pivot table. It will have 10 rows
sheet.add_pivot_table "A#{n_row + 2}:C#{n_row + 10}", "L1:L#{n_row}" do |pivot_table|
pivot_table.rows = ['Group']
pivot_table.data = [ref: 'Group', :subtotal => 'count', num_fmt: 4]
end
# create chart
sheet.add_chart(Axlsx::Bar3DChart, start_at: "D#{n_row + 2}", end_at: "E#{n_row + 20}") do |chart|
chart.add_series data: sheet["B#{n_row + 5}:B#{n_row + 10}"],
labels: sheet["A#{n_row + 5}:A#{n_row + 10}"],
title: "Graph by groups",
colors: @products.map { "00FF00" }
end
by TheR
Upvotes: 0
Views: 45