Created
August 11, 2016 12:30
-
-
Save vastus/ac4a3deca037a56b2da6e07495279d69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'axlsx' | |
| require 'byebug' | |
| rows = [ | |
| [nil, nil, nil, "Mitkä seikat"], | |
| ["Etunimi", "Sukunimi", "HETU", "Esimies", "Ympäristö", "Työtehtävä", "Kuormitus"], | |
| ["Olli", "Isometsä", "123456-000X", "Kyllä", "Ei", "Kyllä"], | |
| ] | |
| Axlsx::Package.new do |p| | |
| p.workbook do |wb| | |
| styles = wb.styles | |
| boldie = styles.add_style(bg_color: "1e1e1e", fg_color: "fefefe", b: true) | |
| p.workbook.add_worksheet(:name => "Pie Chart") do |sheet| | |
| # rows.each { |row| sheet.add_row(row) } | |
| rows.each { |row| sheet.add_row(row, style: boldie) } | |
| sheet.merge_cells("#{Axlsx.cell_r(3, 0)}:#{Axlsx.cell_r(6, 0)}") | |
| end | |
| end | |
| p.serialize('./tmp/simple.xlsx') | |
| end | |
| # Axlsx::Package.new do |p| | |
| # p.workbook.add_worksheet(:name => "Pie Chart") do |sheet| | |
| # sheet.add_row ["Simple Pie Chart"] | |
| # sheet.add_row ["Simple Pie Chart"] | |
| # %w(first second third).each { |label| sheet.add_row [label, rand(24)+1] } | |
| # sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,5], :end_at => [10, 20], :title => "example 3: Pie Chart") do |chart| | |
| # chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"], :colors => ['FF0000', '00FF00', '0000FF'] | |
| # end | |
| # end | |
| # p.serialize('simple.xlsx') | |
| # end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment