Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make graph on pivot table with axlsx #303

Open
drgcms opened this issue Sep 21, 2023 · 1 comment
Open

How to make graph on pivot table with axlsx #303

drgcms opened this issue Sep 21, 2023 · 1 comment
Labels
stale Will be closed soon if there are no updates.

Comments

@drgcms
Copy link

drgcms commented Sep 21, 2023

If I try to make a graph on a result of a pivot table, the program ends 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 anyway?

    n_row = 223  # row number that program ended preparing data
    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

   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

Copy link

This issue has been automatically marked as stale because it has not been commented on for at least three months.
If you have any new information or updates please reply in order to keep the issue open.

@github-actions github-actions bot added the stale Will be closed soon if there are no updates. label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Will be closed soon if there are no updates.
Projects
None yet
Development

No branches or pull requests

1 participant