Last active
August 29, 2015 14:27
-
-
Save bradland/584391ec594b3027eb69 to your computer and use it in GitHub Desktop.
This file contains 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 'pry' | |
p = Axlsx::Package.new | |
wb = p.workbook | |
# Build up a matrix of data | |
cols = ("A".."L").to_a | |
rows = (1..100).map do |i| | |
cols.zip(cols.dup.fill(i.to_s)).map(&:join) | |
end | |
wb.add_worksheet(:name => "Basic Worksheet") do |sheet| | |
rows.each do |row| | |
sheet.add_row row | |
end | |
wb.add_defined_name("'Basic Worksheet'!$A$1:$L$51", :local_sheet_id => sheet.index, :name => '_xlnm.Print_Area') | |
wb.add_defined_name("'Basic Worksheet'!$1:$1", :local_sheet_id => sheet.index, :name => '_xlnm.Print_Titles') | |
wb.add_defined_name("'Basic Worksheet'!$A$1:$B$1", :local_sheet_id => sheet.index, :name => 'Example_Range') | |
end | |
p.serialize "#{File.basename(__FILE__, '.rb')}.xlsx" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment