examples/example.rb in axlsx-1.3.4 vs examples/example.rb in axlsx-1.3.5
- old
+ new
@@ -12,17 +12,19 @@
examples << :custom_borders
examples << :surrounding_border
examples << :deep_custom_borders
examples << :row_column_style
examples << :fixed_column_width
+examples << :outline_level
examples << :merge_cells
examples << :images
examples << :format_dates
examples << :mbcs
examples << :formula
examples << :auto_filter
examples << :data_types
+examples << :override_data_types
examples << :hyperlinks
examples << :number_currency_format
examples << :venezuela_currency
examples << :bar_chart
examples << :chart_gridlines
@@ -41,11 +43,11 @@
examples << :sheet_view
examples << :conditional_formatting
examples << :streaming
examples << :shared_strings
examples << :no_autowidth
-
+examples << :cached_formula
p = Axlsx::Package.new
wb = p.workbook
#```
## A Simple Workbook
@@ -235,10 +237,21 @@
sheet.add_row ["I use autowidth and am very wide", "I use a custom width and am narrow"]
sheet.add_row ['abcdefg', 'This is a very long text and should flow into the right cell', nil, 'xxx' ]
sheet.column_widths nil, 3, 5, nil
end
end
+
+#```ruby
+if examples.include? :outline_level
+ wb.add_worksheet(name: 'outline_level') do |sheet|
+ sheet.add_row [1, 2, 3, Time.now, 5, 149455.15]
+ sheet.add_row [1, 2, 5, 6, 5,14100.19]
+ sheet.add_row [9500002267, 1212, 1212, 5,14100.19]
+ sheet.outline_level_rows 0, 2
+ sheet.outline_level_columns 0, 2
+ end
+end
##```
##Merging Cells.
#```ruby
@@ -342,10 +355,16 @@
sheet.add_row ["Date", "Time", "String", "Boolean", "Float", "Integer"]
sheet.add_row [Date.today, Time.now, "value", true, 0.1, 1], :style => [date_format, time_format]
end
end
+#```ruby
+if examples.include? :override_data_types
+ wb.add_worksheet(:name => "Override Data Type") do |sheet|
+ sheet.add_row ['dont eat my zeros!', '0088'] , :types => [nil, :string]
+ end
+end
# Hyperlinks in worksheet
if examples.include? :hyperlinks
wb.add_worksheet(:name => 'hyperlinks') do |sheet|
# external references
sheet.add_row ['axlsx']
@@ -488,11 +507,11 @@
#```ruby
if examples.include? :fit_to_page
wb.add_worksheet(:name => "fit to page") do |sheet|
sheet.add_row ['this all goes on one page']
- sheet.fit_to_page = true
+ sheet.page_setup.fit_to :width => 1, :height => 1
end
end
##```
@@ -500,11 +519,11 @@
#```ruby
if examples.include? :hide_gridlines
wb.add_worksheet(:name => "No Gridlines") do |sheet|
sheet.add_row ["This", "Sheet", "Hides", "Gridlines"]
- sheet.show_gridlines = false
+ sheet.sheet_view.show_grid_lines = false
end
end
##```
# Repeat printing of header rows.
@@ -702,26 +721,29 @@
p.use_shared_strings = true
p.serialize("shared_strings_example.xlsx")
end
#```
-#p.validate do |er|
-#puts er.inspect
-#end
-##Disabling Autowidth
-
#```ruby
if examples.include? :no_autowidth
p = Axlsx::Package.new
p.use_autowidth = false
wb = p.workbook
wb.add_worksheet(:name => "Manual Widths") do | sheet |
sheet.add_row ['oh look! no autowidth']
end
- p.validate.each { |e| puts e.message }
p.serialize("no-use_autowidth.xlsx")
end
#```
+if examples.include? :cached_formula
+ p = Axlsx::Package.new
+ p.use_shared_strings = true
+ wb = p.workbook
+ wb.add_worksheet(:name => "cached formula") do | sheet |
+ sheet.add_row [1, 2, '=A1+B1'], :formula_values => [nil, nil, 3]
+ end
+ p.serialize 'cached_formula.xlsx'
+end