繁体   English   中英

使用Axlsx gem创建引用另一个工作表的条形图

[英]Using Axlsx gem to create a bar chart that references another sheet

我目前正在使用Axlsx gem在Excel中创建条形图。 但是,我试图在一张纸上创建一个条形图,该条形图引用另一张纸上的值,但遇到错误。

这是我的代码:

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

尚未找到解决方案。 同时,一种解决方法是将所需的数据调用到当前工作表上,并使用这些值创建图表。 所以我做了:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM