簡體   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