[英]Using Axlsx gem to create a bar chart that references another sheet
I'm currently using the Axlsx gem to create bar charts in excel. 我目前正在使用Axlsx gem在Excel中创建条形图。 However, I'm trying to create a bar chart on one sheet that references values on another sheet but am running into errors. 但是,我试图在一张纸上创建一个条形图,该条形图引用另一张纸上的值,但遇到错误。
Here's my code: 这是我的代码:
sheet.add_chart(Axlsx::Bar3DChart, :start_at => "B5", :end_at => "I25", :title=> "Top Weight Step (0.5-15) Volume Month over Month", :barDir => :col) do |bars|
bars.add_series :data => sheet["'Weightsteps Month over Month'!F10:F25"],
:labels => sheet["'Weightsteps Month over Month'!B10:B25"],
:title => sheet["'Weightsteps Month over Month'!F9"]
bars.valAxis.gridlines = false
bars.catAxis.gridlines = false
end
Haven't been able to find a solution. 尚未找到解决方案。 In the meantime a workaround would just to be to call the data you need onto the current sheet and create the chart using those values. 同时,一种解决方法是将所需的数据调用到当前工作表上,并使用这些值创建图表。 So instead I did: 所以我做了:
15.times do |count|
sheet.add_row ["='Weightsteps Month over Month'!B#{count}",
"='Weightsteps Month over Month'!C#{count}"]
end
sheet.add_chart(Axlsx::Bar3DChart,
:start_at => "D5",
:end_at => "I20",
:title=> "Top Weight Step (0.5-15) Volume Month over Month",
:barDir => :col) do |bars|
bars.add_series
:data => sheet["A1:A15"],
:labels => sheet["B1:B15"]
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.