examples/example.rb in axlsx-1.0.16 vs examples/example.rb in axlsx-1.0.17
- old
+ new
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
- require 'axlsx'
+ require 'axlsx.rb'
p = Axlsx::Package.new
wb = p.workbook
#A Simple Workbook
@@ -185,12 +185,29 @@
sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
sheet.auto_filter = "A2:D5"
end
+##Specifying Column Widths
+
+ wb.add_worksheet(:name => "custom column widths") do |sheet|
+ sheet.add_row ["I use autowidth and am very wide", "I use a custom width and am narrow"]
+ sheet.column_widths nil, 3
+ end
+
##Validate and Serialize
p.validate.each { |e| puts e.message }
p.serialize("example.xlsx")
+
+ s = p.to_stream()
+ File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
+
+
+##Using Shared Strings
+
+ p.use_shared_strings = true
+ p.serialize("shared_strings_example.xlsx")
+