From 0a8c8cde8bf55d2f0f3b5ae26e38d7d4bda8a625 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Mon, 21 Nov 2011 19:46:07 +0900 Subject: Readme update with better examples --- .yardoc/checksums | 2 +- .yardoc/objects/root.dat | Bin 406444 -> 406538 bytes README.md | 143 +++++----- assets/example.rb | 176 +++++-------- doc/Axlsx.html | 4 +- doc/Axlsx/App.html | 2 +- doc/Axlsx/Axis.html | 2 +- doc/Axlsx/Bar3DChart.html | 2 +- doc/Axlsx/BarSeries.html | 2 +- doc/Axlsx/Border.html | 2 +- doc/Axlsx/BorderPr.html | 2 +- doc/Axlsx/CatAxis.html | 2 +- doc/Axlsx/Cell.html | 2 +- doc/Axlsx/CellAlignment.html | 2 +- doc/Axlsx/CellProtection.html | 2 +- doc/Axlsx/CellStyle.html | 2 +- doc/Axlsx/Chart.html | 2 +- doc/Axlsx/Color.html | 2 +- doc/Axlsx/ContentType.html | 2 +- doc/Axlsx/Core.html | 2 +- doc/Axlsx/DataTypeValidator.html | 2 +- doc/Axlsx/Default.html | 2 +- doc/Axlsx/Drawing.html | 2 +- doc/Axlsx/Fill.html | 2 +- doc/Axlsx/Font.html | 2 +- doc/Axlsx/GradientFill.html | 2 +- doc/Axlsx/GradientStop.html | 2 +- doc/Axlsx/GraphicFrame.html | 2 +- doc/Axlsx/Marker.html | 2 +- doc/Axlsx/NumFmt.html | 2 +- doc/Axlsx/Override.html | 2 +- doc/Axlsx/Package.html | 2 +- doc/Axlsx/PatternFill.html | 2 +- doc/Axlsx/Pie3DChart.html | 2 +- doc/Axlsx/PieSeries.html | 2 +- doc/Axlsx/RegexValidator.html | 2 +- doc/Axlsx/Relationship.html | 2 +- doc/Axlsx/Relationships.html | 2 +- doc/Axlsx/RestrictionValidator.html | 2 +- doc/Axlsx/Row.html | 2 +- doc/Axlsx/Scaling.html | 2 +- doc/Axlsx/Series.html | 2 +- doc/Axlsx/SimpleTypedList.html | 2 +- doc/Axlsx/Styles.html | 2 +- doc/Axlsx/TableStyle.html | 2 +- doc/Axlsx/TableStyleElement.html | 2 +- doc/Axlsx/TableStyles.html | 2 +- doc/Axlsx/Title.html | 2 +- doc/Axlsx/TwoCellAnchor.html | 2 +- doc/Axlsx/ValAxis.html | 2 +- doc/Axlsx/View3D.html | 2 +- doc/Axlsx/Workbook.html | 2 +- doc/Axlsx/Worksheet.html | 2 +- doc/Axlsx/Xf.html | 2 +- doc/_index.html | 2 +- doc/file.README.html | 128 +++++---- doc/index.html | 128 +++++---- doc/method_list.html | 512 ++++++++++++++++++------------------ doc/top-level-namespace.html | 2 +- 59 files changed, 555 insertions(+), 640 deletions(-) diff --git a/.yardoc/checksums b/.yardoc/checksums index 47b5312e..ebcb2a47 100644 --- a/.yardoc/checksums +++ b/.yardoc/checksums @@ -4,7 +4,7 @@ lib/axlsx/drawing/pie_3D_chart.rb 9a93a6fcf43122ed41f522f50b9d0d0340be1688 lib/axlsx/stylesheet/border_pr.rb 09dcb61ec7b0cf49f2da4c4f8ccba8f7e0df7b07 lib/axlsx/stylesheet/color.rb 4927aaebe27dda42d78bb7baf9a44edc1753c77f lib/axlsx/drawing/marker.rb 3507738522c02a3733a01f115d9ef22fae4ea542 -lib/axlsx/util/constants.rb 3441c292d88c3c1c7ab4c5f15d3ac2a434b3b87b +lib/axlsx/util/constants.rb ebb670bf42bffc225281bcec13e654118603c698 lib/axlsx/stylesheet/cell_protection.rb ce494f9add6de0a51407ddd9122fffe95759a48a lib/axlsx/stylesheet/cell_style.rb 46c6ff183bce5c6b1ab6228823257d638007b03c lib/axlsx/drawing/series.rb 76a9b00ab44c4b9553a017aa25f7f504c2b41484 diff --git a/.yardoc/objects/root.dat b/.yardoc/objects/root.dat index 0ed117e7..24b29118 100644 Binary files a/.yardoc/objects/root.dat and b/.yardoc/objects/root.dat differ diff --git a/README.md b/README.md index a826fd5a..455114a8 100644 --- a/README.md +++ b/README.md @@ -40,88 +40,77 @@ To install Axlsx, use the following command: Usage ----- -Simple Workbook - p = Axlsx::Package.new do |package| - package.workbook.add_worksheet do |sheet| - sheet.add_row ["First", "Second", "Third"] - sheet.add_row [1, 2, 3] + require 'rubygems' + require 'axlsx' + +##A Simple Workbook + p = Axlsx::Package.new + p.workbook.add_worksheet do |sheet| + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + end + p.serialize("example1.xlsx") + +##Generating A Bar Chart + p = Axlsx::Package.new + p.workbook.add_worksheet do |sheet| + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart| + chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells end - package.serialize("example1.xlsx") end - -Generating A Bar Chart - - p = Axlsx::Package.new do |package| - package.workbook.add_worksheet do |sheet| - sheet.add_row ["First", "Second", "Third"] - sheet.add_row [1, 2, 3] - sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart| - chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells - end - end - package.serialize("example1.xlsx") - end - -Generating A Pie Chart - - p = Axlsx::Package.new do |package| - package.workbook.add_worksheet do |sheet| - sheet.add_row ["First", "Second", "Third"] - sheet.add_row [1, 2, 3] - sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart| - chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells - end - end - package.serialize("example3.xlsx") - end - -Using Custom Styles - - p = Axlsx::Package.new do |package| - style_options = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } } - header_style = package.workbook.styles.add_style style_options - package.workbook.add_worksheet do |sheet| - sheet.add_row ["Text Autowidth", "Second", "Third"], :style => header_style - sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER - end - package.serialize("example3.xlsx") - end - -Cell Specifc Styles - - p = Axlsx::Package.new do |package| - - black_cell_spec = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } } - blue_cell_spec = { :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } } - - black_cell = package.workbook.styles.add_style black_cell_spec - blue_cell = package.workbook.styles.add_style blue_cell_spec - - # date1904 support. uncomment the line below if you are working on a mac. - # package.workbook.date1904 = true - - package.workbook.add_worksheet do |sheet| - sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell] - sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER - end - package.serialize("example3.xlsx") - end - -Number and Date formatting - - p = Axlsx::Package.new do |package| - date = package.workbook.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER - padded = package.workbook.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER - percent = package.workbook.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER - - package.workbook.add_worksheet do |sheet| - sheet.add_row - sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER - sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded] + p.serialize("example2.xlsx") + +##Generating A Pie Chart + p = Axlsx::Package.new + p.workbook.add_worksheet do |sheet| + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart| + chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells end - package.serialize("example5.xlsx") end + p.serialize("example3.xlsx") + +##Using Custom Styles + + p = Axlsx::Package.new + wb = p.workbook + black_cell = wb.styles.add_style :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } + blue_cell = wb.styles.add_style :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } + wb.add_worksheet do |sheet| + sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell] + sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER + end + p.serialize("example4.xlsx") + +##Using Custom Formatting and date1904 + + p = Axlsx::Package.new + wb = p.workbook + date = wb.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER + padded = wb.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER + percent = wb.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER + wb.date1904 = true # required for generation on mac + wb.add_worksheet do |sheet| + sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER + sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded] + end + p.serialize("example5.xlsx") + +##Validation + + p = Axlsx::Package.new + p.workbook.add_worksheet do |sheet| + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + end + + p.validate.each do |error| + puts error.inspect + end ### Documentation This gem is 100% documented with YARD, an exceptional documentation library. To see documentation for this, and all the gems installed on your system use: diff --git a/assets/example.rb b/assets/example.rb index aaaf3970..b3fe6f54 100644 --- a/assets/example.rb +++ b/assets/example.rb @@ -1,128 +1,70 @@ -require 'rubygems' -require 'axlsx' + require 'rubygems' + require 'axlsx' -p = Axlsx::Package.new do |package| - package.workbook.add_worksheet do |sheet| - sheet.add_row ["First", "Second", "Third"], :style => Axlsx::STYLE_THIN_BORDER - sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER - sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart| - chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells - end - end - package.serialize("example1.xlsx") -end +#A Simple Workbook + p = Axlsx::Package.new + p.workbook.add_worksheet do |sheet| + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + end + p.serialize("example1.xlsx") -p = Axlsx::Package.new do |package| - header_style = package.workbook.styles.add_style :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => {:horizontal => :center } - package.workbook.add_worksheet do |sheet| - sheet.add_row ["First", "Second", "Third"], :style => header_style - sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER - sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart| - chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells - end - end - package.serialize("example3.xlsx") -end - -p = Axlsx::Package.new do |package| - black_cell_spec = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } } - blue_cell_spec = { :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } } - - black_cell = package.workbook.styles.add_style black_cell_spec - blue_cell = package.workbook.styles.add_style blue_cell_spec - - package.workbook.add_worksheet do |sheet| - sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell] - sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER - end - package.serialize("example4.xlsx") -end -# example 5 - p = Axlsx::Package.new do |package| - date = package.workbook.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER - padded = package.workbook.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER - percent = package.workbook.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER - package.workbook.date1904 = true - package.workbook.add_worksheet do |sheet| - sheet.add_row - sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER - sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded] +#Generating A Bar Chart + p = Axlsx::Package.new + p.workbook.add_worksheet do |sheet| + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart| + chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells end - package.serialize("example5.xlsx") end + p.serialize("example2.xlsx") -p = Axlsx::Package.new -wb = p.workbook - -styles = wb.styles - -header_style = styles.add_style(:bg_color=>"FF000000", :fg_color=>"FFFFFFFF", :sz=>14, :alignment=>{:horizontal=>:center}) -table_title = styles.add_style :sz=>22 -date_time = styles.add_style(:num_fmt=>Axlsx::NUM_FMT_YYYYMMDDHHMMSS) -date = styles.add_style :num_fmt=>Axlsx::NUM_FMT_YYYYMMDD -bordered = styles.add_style :border=>Axlsx::STYLE_THIN_BORDER - -wb.add_worksheet do |sheet| - sheet.name = "Example 1" - # add cells as a row - sheet.add_row ['Example 1 Styling and Bar Chart'], :style=>table_title - sheet.add_row ["Formatted Time Stamp", Time.now],:style=>[nil, date_time] - # adding cells one at a time - sheet.add_row do |row| - row.add_cell "Formatted Date" - row.add_cell Time.now, :style => date, :type=>:time - end +#Generating A Pie Chart + p = Axlsx::Package.new + p.workbook.add_worksheet do |sheet| + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart| + chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells + end + end + p.serialize("example3.xlsx") - # Bar 3D Chart - sheet.add_row - label_row = sheet.add_row ["0 ~ 10", "11 ~ 20", "21 ~ 60"], :style=>header_style - data_row = sheet.add_row [12, 60, 25], :style=>bordered - sheet.add_chart(Axlsx::Bar3DChart, :show_legend=>false) do |chart| - chart.title = Axlsx::Title.new(sheet.rows.first.cells.first) - chart.add_series :data => data_row.cells, :labels => label_row.cells - chart.start_at.coord(0, 7) - chart.end_at.coord(3, 17) - end +#Using Custom Styles -end + p = Axlsx::Package.new + wb = p.workbook + black_cell = wb.styles.add_style :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } + blue_cell = wb.styles.add_style :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } + wb.add_worksheet do |sheet| + sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell] + sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER + end + p.serialize("example4.xlsx") -# Blocks are not required -percent = styles.add_style :num_fmt=>Axlsx::NUM_FMT_PERCENT, :border=>Axlsx::STYLE_THIN_BORDER -wb.add_worksheet(:name=>"Example 2") do |sheet| - sheet.add_row ["Example 2 - Styling and Pie Chart"], :style=>table_title - label_row = sheet.add_row(["Summer", "Fall", "Winter", "Spring"], :style=>header_style) - data_row = sheet.add_row [0.5, 0.2, 0.2, 0.1], :style=>percent - chart = sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,4], :end_at => [4,14], :title => "Pie Consumption per Season") do |chart| - chart.add_series :data => data_row.cells, :labels=>label_row.cells - end -end -# Charts can be build with out data in the sheet -wb.add_worksheet(:name=>"Example 3") do |ws| - ws.add_row ["Charts can be build without any data in the worksheet"] - ws.add_chart(Axlsx::Pie3DChart, :title=>"free chart 1") do |chart| - chart.start_at.coord(0,2) - chart.end_at.coord(3,12) - chart.add_series :data => [13,54,1], :labels=>["nothing","in","the sheet"] - end - ws.add_chart(Axlsx::Pie3DChart) do |chart| - chart.start_at.coord(0,13) - chart.end_at.coord(3,23) - chart.add_series :data => [1,4,5], :labels=>["nothing","in","the sheet"], :title=>"free chart 2" - end -end +#Using Custom Formatting and date1904 -# wb.add_worksheet(:name=>"Example 4") do |sheet| -# sheet.add_row ["lots of data!"] -# (1..100).each do |i| -# cells = (1..50).map { |i| rand(5 ** 10) } -# sheet.add_row cells -# end -# end + p = Axlsx::Package.new + wb = p.workbook + date = wb.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER + padded = wb.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER + percent = wb.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER + wb.date1904 = true # required for generation on mac + wb.add_worksheet do |sheet| + sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER + sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded] + end + p.serialize("example5.xlsx") -errors = p.validate -if errors.empty? - p.serialize('test.xlsx') -else - puts errors.to_s -end +#Validation + p = Axlsx::Package.new + p.workbook.add_worksheet do |sheet| + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + end + p.validate.each do |error| + puts error.inspect + end + diff --git a/doc/Axlsx.html b/doc/Axlsx.html index 78ff81c7..bd7f61fd 100644 --- a/doc/Axlsx.html +++ b/doc/Axlsx.html @@ -122,7 +122,7 @@ version -
"1.0.3"
+        
"1.0.4"
 
ENCODING = @@ -2434,7 +2434,7 @@ The value validated diff --git a/doc/Axlsx/App.html b/doc/Axlsx/App.html index 5ccf2477..ceacd9b7 100644 --- a/doc/Axlsx/App.html +++ b/doc/Axlsx/App.html @@ -2631,7 +2631,7 @@ The document as a string diff --git a/doc/Axlsx/Axis.html b/doc/Axlsx/Axis.html index 18e077ff..bd28e976 100644 --- a/doc/Axlsx/Axis.html +++ b/doc/Axlsx/Axis.html @@ -1038,7 +1038,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Bar3DChart.html b/doc/Axlsx/Bar3DChart.html index 087b6b67..1d6f3539 100644 --- a/doc/Axlsx/Bar3DChart.html +++ b/doc/Axlsx/Bar3DChart.html @@ -1144,7 +1144,7 @@ Serializes the bar chart diff --git a/doc/Axlsx/BarSeries.html b/doc/Axlsx/BarSeries.html index 916c6c8f..5384a077 100644 --- a/doc/Axlsx/BarSeries.html +++ b/doc/Axlsx/BarSeries.html @@ -753,7 +753,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Border.html b/doc/Axlsx/Border.html index fd1385dc..24d11058 100644 --- a/doc/Axlsx/Border.html +++ b/doc/Axlsx/Border.html @@ -766,7 +766,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/BorderPr.html b/doc/Axlsx/BorderPr.html index ba2a29f6..f9a93ed0 100644 --- a/doc/Axlsx/BorderPr.html +++ b/doc/Axlsx/BorderPr.html @@ -700,7 +700,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/CatAxis.html b/doc/Axlsx/CatAxis.html index 3415b79b..891168a1 100644 --- a/doc/Axlsx/CatAxis.html +++ b/doc/Axlsx/CatAxis.html @@ -757,7 +757,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Cell.html b/doc/Axlsx/Cell.html index cc824eec..9f90513f 100644 --- a/doc/Axlsx/Cell.html +++ b/doc/Axlsx/Cell.html @@ -1614,7 +1614,7 @@ xml text for the cell diff --git a/doc/Axlsx/CellAlignment.html b/doc/Axlsx/CellAlignment.html index 0865cbb5..07651c06 100644 --- a/doc/Axlsx/CellAlignment.html +++ b/doc/Axlsx/CellAlignment.html @@ -1238,7 +1238,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/CellProtection.html b/doc/Axlsx/CellProtection.html index 809bab9e..9f0d06d6 100644 --- a/doc/Axlsx/CellProtection.html +++ b/doc/Axlsx/CellProtection.html @@ -556,7 +556,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/CellStyle.html b/doc/Axlsx/CellStyle.html index 8cb02ba4..f3dfc76b 100644 --- a/doc/Axlsx/CellStyle.html +++ b/doc/Axlsx/CellStyle.html @@ -940,7 +940,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Chart.html b/doc/Axlsx/Chart.html index 4a612aca..d60170e6 100644 --- a/doc/Axlsx/Chart.html +++ b/doc/Axlsx/Chart.html @@ -1360,7 +1360,7 @@ Chart Serialization serializes the chart diff --git a/doc/Axlsx/Color.html b/doc/Axlsx/Color.html index 60e142a1..9a5fdbc8 100644 --- a/doc/Axlsx/Color.html +++ b/doc/Axlsx/Color.html @@ -656,7 +656,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/ContentType.html b/doc/Axlsx/ContentType.html index 3880eaec..72b5f52c 100644 --- a/doc/Axlsx/ContentType.html +++ b/doc/Axlsx/ContentType.html @@ -331,7 +331,7 @@ The document as a string. diff --git a/doc/Axlsx/Core.html b/doc/Axlsx/Core.html index 0a4e5ed6..2b9f51f4 100644 --- a/doc/Axlsx/Core.html +++ b/doc/Axlsx/Core.html @@ -456,7 +456,7 @@ time when this method is called. diff --git a/doc/Axlsx/DataTypeValidator.html b/doc/Axlsx/DataTypeValidator.html index 6ce1762d..31b3bb99 100644 --- a/doc/Axlsx/DataTypeValidator.html +++ b/doc/Axlsx/DataTypeValidator.html @@ -315,7 +315,7 @@ types or the block passed returns false diff --git a/doc/Axlsx/Default.html b/doc/Axlsx/Default.html index b7be4fac..961e096e 100644 --- a/doc/Axlsx/Default.html +++ b/doc/Axlsx/Default.html @@ -566,7 +566,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Drawing.html b/doc/Axlsx/Drawing.html index 21afe10e..e6f1fb51 100644 --- a/doc/Axlsx/Drawing.html +++ b/doc/Axlsx/Drawing.html @@ -1145,7 +1145,7 @@ Serializes the drawing diff --git a/doc/Axlsx/Fill.html b/doc/Axlsx/Fill.html index f81853e3..65103017 100644 --- a/doc/Axlsx/Fill.html +++ b/doc/Axlsx/Fill.html @@ -451,7 +451,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Font.html b/doc/Axlsx/Font.html index 54f607fa..8e829ac3 100644 --- a/doc/Axlsx/Font.html +++ b/doc/Axlsx/Font.html @@ -1545,7 +1545,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/GradientFill.html b/doc/Axlsx/GradientFill.html index 91b411c5..bfc9407a 100644 --- a/doc/Axlsx/GradientFill.html +++ b/doc/Axlsx/GradientFill.html @@ -1017,7 +1017,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/GradientStop.html b/doc/Axlsx/GradientStop.html index 232eaaaa..51727c98 100644 --- a/doc/Axlsx/GradientStop.html +++ b/doc/Axlsx/GradientStop.html @@ -517,7 +517,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/GraphicFrame.html b/doc/Axlsx/GraphicFrame.html index 4b00c70c..6c259d82 100644 --- a/doc/Axlsx/GraphicFrame.html +++ b/doc/Axlsx/GraphicFrame.html @@ -637,7 +637,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Marker.html b/doc/Axlsx/Marker.html index c34a2c6a..b7212a79 100644 --- a/doc/Axlsx/Marker.html +++ b/doc/Axlsx/Marker.html @@ -848,7 +848,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/NumFmt.html b/doc/Axlsx/NumFmt.html index 08ccb543..afe2086f 100644 --- a/doc/Axlsx/NumFmt.html +++ b/doc/Axlsx/NumFmt.html @@ -553,7 +553,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Override.html b/doc/Axlsx/Override.html index d265aa93..23d29842 100644 --- a/doc/Axlsx/Override.html +++ b/doc/Axlsx/Override.html @@ -559,7 +559,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Package.html b/doc/Axlsx/Package.html index cd969a29..a9007719 100644 --- a/doc/Axlsx/Package.html +++ b/doc/Axlsx/Package.html @@ -1284,7 +1284,7 @@ An array of all validation errors encountered. diff --git a/doc/Axlsx/PatternFill.html b/doc/Axlsx/PatternFill.html index e48ae5f4..3dcc6dd9 100644 --- a/doc/Axlsx/PatternFill.html +++ b/doc/Axlsx/PatternFill.html @@ -672,7 +672,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Pie3DChart.html b/doc/Axlsx/Pie3DChart.html index a9cc3c67..ec7187c3 100644 --- a/doc/Axlsx/Pie3DChart.html +++ b/doc/Axlsx/Pie3DChart.html @@ -430,7 +430,7 @@ Serializes the pie chart diff --git a/doc/Axlsx/PieSeries.html b/doc/Axlsx/PieSeries.html index ae99a489..aa9adfee 100644 --- a/doc/Axlsx/PieSeries.html +++ b/doc/Axlsx/PieSeries.html @@ -753,7 +753,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/RegexValidator.html b/doc/Axlsx/RegexValidator.html index 49fe4a80..3d0b4c97 100644 --- a/doc/Axlsx/RegexValidator.html +++ b/doc/Axlsx/RegexValidator.html @@ -259,7 +259,7 @@ The value to validate. diff --git a/doc/Axlsx/Relationship.html b/doc/Axlsx/Relationship.html index 600f4ae1..16e1e3e6 100644 --- a/doc/Axlsx/Relationship.html +++ b/doc/Axlsx/Relationship.html @@ -545,7 +545,7 @@ the reference id of the object. diff --git a/doc/Axlsx/Relationships.html b/doc/Axlsx/Relationships.html index 79b9f017..e7b973ef 100644 --- a/doc/Axlsx/Relationships.html +++ b/doc/Axlsx/Relationships.html @@ -334,7 +334,7 @@ Serializes the relationships document. diff --git a/doc/Axlsx/RestrictionValidator.html b/doc/Axlsx/RestrictionValidator.html index a3fd5cb2..a6441a7d 100644 --- a/doc/Axlsx/RestrictionValidator.html +++ b/doc/Axlsx/RestrictionValidator.html @@ -291,7 +291,7 @@ Raised if the value provided is not in the list of choices. diff --git a/doc/Axlsx/Row.html b/doc/Axlsx/Row.html index c33af64a..d7e6d669 100644 --- a/doc/Axlsx/Row.html +++ b/doc/Axlsx/Row.html @@ -762,7 +762,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Scaling.html b/doc/Axlsx/Scaling.html index 2169a2d7..a2a24dbf 100644 --- a/doc/Axlsx/Scaling.html +++ b/doc/Axlsx/Scaling.html @@ -731,7 +731,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Series.html b/doc/Axlsx/Series.html index 97dce3d5..5da758f4 100644 --- a/doc/Axlsx/Series.html +++ b/doc/Axlsx/Series.html @@ -741,7 +741,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/SimpleTypedList.html b/doc/Axlsx/SimpleTypedList.html index 343d2e90..bc3e4b5f 100644 --- a/doc/Axlsx/SimpleTypedList.html +++ b/doc/Axlsx/SimpleTypedList.html @@ -1608,7 +1608,7 @@ Unlock the list diff --git a/doc/Axlsx/Styles.html b/doc/Axlsx/Styles.html index ec5b305a..0fca6383 100644 --- a/doc/Axlsx/Styles.html +++ b/doc/Axlsx/Styles.html @@ -1745,7 +1745,7 @@ Serializes the styles document diff --git a/doc/Axlsx/TableStyle.html b/doc/Axlsx/TableStyle.html index 2c47f51d..c8f1f93c 100644 --- a/doc/Axlsx/TableStyle.html +++ b/doc/Axlsx/TableStyle.html @@ -701,7 +701,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/TableStyleElement.html b/doc/Axlsx/TableStyleElement.html index f7a0978c..885d8e15 100644 --- a/doc/Axlsx/TableStyleElement.html +++ b/doc/Axlsx/TableStyleElement.html @@ -668,7 +668,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/TableStyles.html b/doc/Axlsx/TableStyles.html index f30dd2ca..fdb60660 100644 --- a/doc/Axlsx/TableStyles.html +++ b/doc/Axlsx/TableStyles.html @@ -590,7 +590,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Title.html b/doc/Axlsx/Title.html index fa912ed9..c55d9b51 100644 --- a/doc/Axlsx/Title.html +++ b/doc/Axlsx/Title.html @@ -612,7 +612,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/TwoCellAnchor.html b/doc/Axlsx/TwoCellAnchor.html index f4ace1f0..b5ef9a71 100644 --- a/doc/Axlsx/TwoCellAnchor.html +++ b/doc/Axlsx/TwoCellAnchor.html @@ -1106,7 +1106,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/ValAxis.html b/doc/Axlsx/ValAxis.html index 2b0c82a7..a1433dc5 100644 --- a/doc/Axlsx/ValAxis.html +++ b/doc/Axlsx/ValAxis.html @@ -530,7 +530,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/View3D.html b/doc/Axlsx/View3D.html index b97af86d..31d98713 100644 --- a/doc/Axlsx/View3D.html +++ b/doc/Axlsx/View3D.html @@ -962,7 +962,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Workbook.html b/doc/Axlsx/Workbook.html index 7bad5705..adbeafcb 100644 --- a/doc/Axlsx/Workbook.html +++ b/doc/Axlsx/Workbook.html @@ -1338,7 +1338,7 @@ Serializes the workbook document diff --git a/doc/Axlsx/Worksheet.html b/doc/Axlsx/Worksheet.html index cbb59658..881561d0 100644 --- a/doc/Axlsx/Worksheet.html +++ b/doc/Axlsx/Worksheet.html @@ -1855,7 +1855,7 @@ of Cell objects diff --git a/doc/Axlsx/Xf.html b/doc/Axlsx/Xf.html index 1cd01143..b8462333 100644 --- a/doc/Axlsx/Xf.html +++ b/doc/Axlsx/Xf.html @@ -1672,7 +1672,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/_index.html b/doc/_index.html index fad580ad..8249c785 100644 --- a/doc/_index.html +++ b/doc/_index.html @@ -566,7 +566,7 @@ diff --git a/doc/file.README.html b/doc/file.README.html index 2024bfa2..10377a44 100644 --- a/doc/file.README.html +++ b/doc/file.README.html @@ -92,93 +92,85 @@ It enables the you to generate 100% valid xlsx files that include customised sty

Usage

-

Simple Workbook

- -
 p = Axlsx::Package.new do |package|
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row ["First", "Second", "Third"]
-     sheet.add_row [1, 2, 3]
-   end
-   package.serialize("example1.xlsx")
- end  
+
 require 'rubygems'
+ require 'axlsx'
 
-

Generating A Bar Chart

+

A Simple Workbook

-
 p = Axlsx::Package.new do |package|
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row ["First", "Second", "Third"]
-     sheet.add_row [1, 2, 3]
-     sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart|
-       chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
-     end
-   end
-   package.serialize("example1.xlsx")
- end  
+
  p = Axlsx::Package.new
+  p.workbook.add_worksheet do |sheet|
+    sheet.add_row ["First", "Second", "Third"]
+    sheet.add_row [1, 2, 3]
+  end
+  p.serialize("example1.xlsx")
 
-

Generating A Pie Chart

+

Generating A Bar Chart

-
 p = Axlsx::Package.new do |package|
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row ["First", "Second", "Third"]
-     sheet.add_row [1, 2, 3]
-     sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart|
-       chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
-     end
+
 p = Axlsx::Package.new
+ p.workbook.add_worksheet do |sheet|
+   sheet.add_row ["First", "Second", "Third"]
+   sheet.add_row [1, 2, 3]
+   sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart|
+     chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
    end
-   package.serialize("example3.xlsx")
  end  
+ p.serialize("example2.xlsx")
 
-

Using Custom Styles

+

Generating A Pie Chart

-
 p = Axlsx::Package.new do |package|
-   style_options = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
-   header_style = package.workbook.styles.add_style style_options
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row ["Text Autowidth", "Second", "Third"], :style => header_style
-     sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
+
 p = Axlsx::Package.new
+ p.workbook.add_worksheet do |sheet|
+   sheet.add_row ["First", "Second", "Third"]
+   sheet.add_row [1, 2, 3]
+   sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart|
+     chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
    end
-   package.serialize("example3.xlsx")
  end  
+ p.serialize("example3.xlsx")
 
-

Cell Specifc Styles

- -
 p = Axlsx::Package.new do |package|
-
-   black_cell_spec = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
-   blue_cell_spec = { :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
-
-   black_cell = package.workbook.styles.add_style black_cell_spec
-   blue_cell = package.workbook.styles.add_style blue_cell_spec
-
-   # date1904 support. uncomment the line below if you are working on a mac.
-   # package.workbook.date1904 = true 
+

Using Custom Styles

+ +
 p = Axlsx::Package.new
+ wb = p.workbook
+ black_cell = wb.styles.add_style :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center }
+ blue_cell = wb.styles.add_style  :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center }
+ wb.add_worksheet do |sheet|
+   sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
+   sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
+ end
+ p.serialize("example4.xlsx")
+
- package.workbook.add_worksheet do |sheet| - sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell] - sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER - end - package.serialize("example3.xlsx") - end +

Using Custom Formatting and date1904

+ +
 p = Axlsx::Package.new
+ wb = p.workbook
+ date = wb.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER
+ padded = wb.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER
+ percent = wb.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER
+ wb.date1904 = true # required for generation on mac
+ wb.add_worksheet do |sheet|
+   sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
+   sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded]
+ end
+ p.serialize("example5.xlsx")
 
-

Number and Date formatting

+

Validation

-
 p = Axlsx::Package.new do |package|
-   date = package.workbook.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER
-   padded = package.workbook.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER
-   percent = package.workbook.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER
+
 p = Axlsx::Package.new
+ p.workbook.add_worksheet do |sheet|
+   sheet.add_row ["First", "Second", "Third"]
+   sheet.add_row [1, 2, 3]
+ end
 
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row
-     sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
-     sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded]
-   end
-   package.serialize("example5.xlsx")
- end  
+ p.validate.each do |error|
+   puts error.inspect
+ end
 

Documentation

@@ -213,7 +205,7 @@ licensed under the MIT license. Please see the diff --git a/doc/index.html b/doc/index.html index 2024bfa2..10377a44 100644 --- a/doc/index.html +++ b/doc/index.html @@ -92,93 +92,85 @@ It enables the you to generate 100% valid xlsx files that include customised sty

Usage

-

Simple Workbook

- -
 p = Axlsx::Package.new do |package|
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row ["First", "Second", "Third"]
-     sheet.add_row [1, 2, 3]
-   end
-   package.serialize("example1.xlsx")
- end  
+
 require 'rubygems'
+ require 'axlsx'
 
-

Generating A Bar Chart

+

A Simple Workbook

-
 p = Axlsx::Package.new do |package|
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row ["First", "Second", "Third"]
-     sheet.add_row [1, 2, 3]
-     sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart|
-       chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
-     end
-   end
-   package.serialize("example1.xlsx")
- end  
+
  p = Axlsx::Package.new
+  p.workbook.add_worksheet do |sheet|
+    sheet.add_row ["First", "Second", "Third"]
+    sheet.add_row [1, 2, 3]
+  end
+  p.serialize("example1.xlsx")
 
-

Generating A Pie Chart

+

Generating A Bar Chart

-
 p = Axlsx::Package.new do |package|
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row ["First", "Second", "Third"]
-     sheet.add_row [1, 2, 3]
-     sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart|
-       chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
-     end
+
 p = Axlsx::Package.new
+ p.workbook.add_worksheet do |sheet|
+   sheet.add_row ["First", "Second", "Third"]
+   sheet.add_row [1, 2, 3]
+   sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart|
+     chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
    end
-   package.serialize("example3.xlsx")
  end  
+ p.serialize("example2.xlsx")
 
-

Using Custom Styles

+

Generating A Pie Chart

-
 p = Axlsx::Package.new do |package|
-   style_options = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
-   header_style = package.workbook.styles.add_style style_options
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row ["Text Autowidth", "Second", "Third"], :style => header_style
-     sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
+
 p = Axlsx::Package.new
+ p.workbook.add_worksheet do |sheet|
+   sheet.add_row ["First", "Second", "Third"]
+   sheet.add_row [1, 2, 3]
+   sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart|
+     chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
    end
-   package.serialize("example3.xlsx")
  end  
+ p.serialize("example3.xlsx")
 
-

Cell Specifc Styles

- -
 p = Axlsx::Package.new do |package|
-
-   black_cell_spec = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
-   blue_cell_spec = { :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
-
-   black_cell = package.workbook.styles.add_style black_cell_spec
-   blue_cell = package.workbook.styles.add_style blue_cell_spec
-
-   # date1904 support. uncomment the line below if you are working on a mac.
-   # package.workbook.date1904 = true 
+

Using Custom Styles

+ +
 p = Axlsx::Package.new
+ wb = p.workbook
+ black_cell = wb.styles.add_style :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center }
+ blue_cell = wb.styles.add_style  :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center }
+ wb.add_worksheet do |sheet|
+   sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
+   sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
+ end
+ p.serialize("example4.xlsx")
+
- package.workbook.add_worksheet do |sheet| - sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell] - sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER - end - package.serialize("example3.xlsx") - end +

Using Custom Formatting and date1904

+ +
 p = Axlsx::Package.new
+ wb = p.workbook
+ date = wb.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER
+ padded = wb.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER
+ percent = wb.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER
+ wb.date1904 = true # required for generation on mac
+ wb.add_worksheet do |sheet|
+   sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
+   sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded]
+ end
+ p.serialize("example5.xlsx")
 
-

Number and Date formatting

+

Validation

-
 p = Axlsx::Package.new do |package|
-   date = package.workbook.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER
-   padded = package.workbook.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER
-   percent = package.workbook.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER
+
 p = Axlsx::Package.new
+ p.workbook.add_worksheet do |sheet|
+   sheet.add_row ["First", "Second", "Third"]
+   sheet.add_row [1, 2, 3]
+ end
 
-   package.workbook.add_worksheet do |sheet|
-     sheet.add_row
-     sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
-     sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded]
-   end
-   package.serialize("example5.xlsx")
- end  
+ p.validate.each do |error|
+   puts error.inspect
+ end
 

Documentation

@@ -213,7 +205,7 @@ licensed under the MIT license. Please see the diff --git a/doc/method_list.html b/doc/method_list.html index 80d1dc52..aede7025 100644 --- a/doc/method_list.html +++ b/doc/method_list.html @@ -89,17 +89,17 @@
  • - #ContentType + #ContentType - Axlsx::Override + Axlsx::Default
  • - #ContentType + #ContentType - Axlsx::Default + Axlsx::Override
  • @@ -617,17 +617,17 @@
  • - #chart + #chart - Axlsx::GraphicFrame + Axlsx::Series
  • - #chart + #chart - Axlsx::Series + Axlsx::GraphicFrame
  • @@ -673,9 +673,9 @@
  • - #color + #color - Axlsx::Font + Axlsx::GradientStop
  • @@ -689,9 +689,9 @@
  • - #color + #color - Axlsx::GradientStop + Axlsx::Font
  • @@ -761,17 +761,17 @@
  • - #data + #data - Axlsx::PieSeries + Axlsx::BarSeries
  • - #data + #data - Axlsx::BarSeries + Axlsx::PieSeries
  • @@ -1065,17 +1065,17 @@
  • - #hidden + #hidden - Axlsx::CellStyle + Axlsx::CellProtection
  • - #hidden + #hidden - Axlsx::CellProtection + Axlsx::CellStyle
  • @@ -1113,41 +1113,41 @@
  • - #index + #index - Axlsx::Chart + Axlsx::Row
  • - #index + #index - Axlsx::Worksheet + Axlsx::TwoCellAnchor
  • - #index + #index - Axlsx::Row + Axlsx::Worksheet
  • - #index + #index - Axlsx::Series + Axlsx::Cell
  • - #index + #index - Axlsx::Cell + Axlsx::Chart
  • @@ -1161,9 +1161,9 @@
  • - #index + #index - Axlsx::TwoCellAnchor + Axlsx::Series
  • @@ -1177,9 +1177,9 @@
  • - #initialize + #initialize - Axlsx::Worksheet + Axlsx::TableStyles
  • @@ -1193,345 +1193,345 @@
  • - #initialize + #initialize - Axlsx::CellStyle + Axlsx::Row
  • - #initialize + #initialize - Axlsx::Workbook + Axlsx::PieSeries
  • - #initialize + #initialize - Axlsx::Border + Axlsx::Default
  • - #initialize + #initialize - Axlsx::Relationships + Axlsx::GraphicFrame
  • - #initialize + #initialize - Axlsx::Drawing + Axlsx::CellAlignment
  • - #initialize + #initialize - Axlsx::Pie3DChart + Axlsx::ValAxis
  • - #initialize + #initialize - Axlsx::BorderPr + Axlsx::CatAxis
  • - #initialize + #initialize - Axlsx::SimpleTypedList + Axlsx::Title
  • - #initialize + #initialize - Axlsx::Bar3DChart + Axlsx::Core
  • - #initialize + #initialize - Axlsx::Core + Axlsx::TwoCellAnchor
  • - #initialize + #initialize - Axlsx::Title + Axlsx::Pie3DChart
  • - #initialize + #initialize - Axlsx::BarSeries + Axlsx::GradientStop
  • - #initialize + #initialize - Axlsx::GradientStop + Axlsx::TableStyleElement
  • - #initialize + #initialize - Axlsx::Chart + Axlsx::Axis
  • - #initialize + #initialize - Axlsx::Color + Axlsx::TableStyle
  • - #initialize + #initialize - Axlsx::NumFmt + Axlsx::View3D
  • - #initialize + #initialize - Axlsx::Cell + Axlsx::Drawing
  • - #initialize + #initialize - Axlsx::GraphicFrame + Axlsx::Override
  • - #initialize + #initialize - Axlsx::TableStyle + Axlsx::Font
  • - #initialize + #initialize - Axlsx::Fill + Axlsx::Package
  • - #initialize + #initialize - Axlsx::Font + Axlsx::Scaling
  • - #initialize + #initialize - Axlsx::PieSeries + Axlsx::Worksheet
  • - #initialize + #initialize - Axlsx::Axis + Axlsx::GradientFill
  • - #initialize + #initialize - Axlsx::TableStyles + Axlsx::PatternFill
  • - #initialize + #initialize - Axlsx::Xf + Axlsx::Workbook
  • - #initialize + #initialize - Axlsx::GradientFill + Axlsx::SimpleTypedList
  • - #initialize + #initialize - Axlsx::CellAlignment + Axlsx::Border
  • - #initialize + #initialize - Axlsx::Default + Axlsx::Marker
  • - #initialize + #initialize - Axlsx::TableStyleElement + Axlsx::CellStyle
  • - #initialize + #initialize - Axlsx::View3D + Axlsx::CellProtection
  • - #initialize + #initialize - Axlsx::Override + Axlsx::Chart
  • - #initialize + #initialize - Axlsx::CatAxis + Axlsx::Xf
  • - #initialize + #initialize - Axlsx::Row + Axlsx::ContentType
  • - #initialize + #initialize - Axlsx::PatternFill + Axlsx::BarSeries
  • - #initialize + #initialize - Axlsx::Package + Axlsx::Fill
  • - #initialize + #initialize - Axlsx::Scaling + Axlsx::Series
  • - #initialize + #initialize - Axlsx::TwoCellAnchor + Axlsx::Styles
  • - #initialize + #initialize - Axlsx::ContentType + Axlsx::Relationships
  • - #initialize + #initialize - Axlsx::ValAxis + Axlsx::NumFmt
  • - #initialize + #initialize - Axlsx::Series + Axlsx::Cell
  • - #initialize + #initialize - Axlsx::Marker + Axlsx::Color
  • - #initialize + #initialize - Axlsx::CellProtection + Axlsx::Bar3DChart
  • - #initialize + #initialize - Axlsx::Styles + Axlsx::BorderPr
  • @@ -1641,41 +1641,41 @@
  • - #name + #name - Axlsx::Worksheet + Axlsx::BorderPr
  • - #name + #name - Axlsx::CellStyle + Axlsx::TableStyle
  • - #name + #name - Axlsx::TableStyle + Axlsx::Font
  • - #name + #name - Axlsx::BorderPr + Axlsx::CellStyle
  • - #name + #name - Axlsx::Font + Axlsx::Worksheet
  • @@ -1777,9 +1777,9 @@
  • - #pn + #pn - Axlsx::Chart + Axlsx::Worksheet
  • @@ -1793,9 +1793,9 @@
  • - #pn + #pn - Axlsx::Worksheet + Axlsx::Chart
  • @@ -1921,25 +1921,25 @@
  • - #relationships + #relationships - Axlsx::Drawing + Axlsx::Worksheet
  • - #relationships + #relationships - Axlsx::Worksheet + Axlsx::Workbook
  • - #relationships + #relationships - Axlsx::Workbook + Axlsx::Drawing
  • @@ -1953,17 +1953,17 @@
  • - #rels_pn + #rels_pn - Axlsx::Worksheet + Axlsx::Drawing
  • - #rels_pn + #rels_pn - Axlsx::Drawing + Axlsx::Worksheet
  • @@ -2001,17 +2001,17 @@
  • - #row + #row - Axlsx::Cell + Axlsx::Marker
  • - #row + #row - Axlsx::Marker + Axlsx::Cell
  • @@ -2153,17 +2153,17 @@
  • - #style + #style - Axlsx::BorderPr + Axlsx::Cell
  • - #style + #style - Axlsx::Cell + Axlsx::BorderPr
  • @@ -2233,17 +2233,17 @@
  • - #title + #title - Axlsx::Chart + Axlsx::Series
  • - #title + #title - Axlsx::Series + Axlsx::Chart
  • @@ -2257,25 +2257,25 @@
  • - #to_xml + #to_xml - Axlsx::BarSeries + Axlsx::GradientStop
  • - #to_xml + #to_xml - Axlsx::Row + Axlsx::Border
  • - #to_xml + #to_xml - Axlsx::Override + Axlsx::Font
  • @@ -2289,329 +2289,329 @@
  • - #to_xml + #to_xml - Axlsx::GradientStop + Axlsx::Color
  • - #to_xml + #to_xml - Axlsx::Axis + Axlsx::Cell
  • - #to_xml + #to_xml - Axlsx::Border + Axlsx::Drawing
  • - #to_xml + #to_xml - Axlsx::Worksheet + Axlsx::CellProtection
  • - #to_xml + #to_xml - Axlsx::Font + Axlsx::TwoCellAnchor
  • - #to_xml + #to_xml - Axlsx::Cell + Axlsx::Styles
  • - #to_xml + #to_xml - Axlsx::PatternFill + Axlsx::Default
  • - #to_xml + #to_xml - Axlsx::GradientFill + Axlsx::Worksheet
  • - #to_xml + #to_xml - Axlsx::Default + Axlsx::TableStyles
  • - #to_xml + #to_xml - Axlsx::CellAlignment + Axlsx::Relationship
  • - #to_xml + #to_xml - Axlsx::CellStyle + Axlsx::ValAxis
  • - #to_xml + #to_xml - Axlsx::Core + Axlsx::Axis
  • - #to_xml + #to_xml - Axlsx::Title + Axlsx::BarSeries
  • - #to_xml + #to_xml - Axlsx::Fill + Axlsx::GraphicFrame
  • - #to_xml + #to_xml - Axlsx::Scaling + Axlsx::CellAlignment
  • - #to_xml + #to_xml - Axlsx::TableStyles + Axlsx::Title
  • - #to_xml + #to_xml - Axlsx::Workbook + Axlsx::Scaling
  • - #to_xml + #to_xml - Axlsx::TwoCellAnchor + Axlsx::Bar3DChart
  • - #to_xml + #to_xml - Axlsx::Xf + Axlsx::Marker
  • - #to_xml + #to_xml - Axlsx::GraphicFrame + Axlsx::View3D
  • - #to_xml + #to_xml - Axlsx::View3D + Axlsx::Fill
  • - #to_xml + #to_xml - Axlsx::Pie3DChart + Axlsx::Core
  • - #to_xml + #to_xml - Axlsx::CatAxis + Axlsx::TableStyleElement
  • - #to_xml + #to_xml - Axlsx::TableStyleElement + Axlsx::NumFmt
  • - #to_xml + #to_xml - Axlsx::Drawing + Axlsx::Xf
  • - #to_xml + #to_xml - Axlsx::App + Axlsx::Workbook
  • - #to_xml + #to_xml - Axlsx::Marker + Axlsx::Chart
  • - #to_xml + #to_xml - Axlsx::Relationship + Axlsx::Pie3DChart
  • - #to_xml + #to_xml - Axlsx::PieSeries + Axlsx::App
  • - #to_xml + #to_xml - Axlsx::Bar3DChart + Axlsx::Row
  • - #to_xml + #to_xml - Axlsx::SimpleTypedList + Axlsx::PatternFill
  • - #to_xml + #to_xml - Axlsx::Chart + Axlsx::CatAxis
  • - #to_xml + #to_xml - Axlsx::Relationships + Axlsx::Override
  • - #to_xml + #to_xml - Axlsx::Styles + Axlsx::PieSeries
  • - #to_xml + #to_xml - Axlsx::BorderPr + Axlsx::CellStyle
  • - #to_xml + #to_xml - Axlsx::ValAxis + Axlsx::Series
  • - #to_xml + #to_xml - Axlsx::CellProtection + Axlsx::SimpleTypedList
  • - #to_xml + #to_xml - Axlsx::NumFmt + Axlsx::ContentType
  • - #to_xml + #to_xml - Axlsx::ContentType + Axlsx::GradientFill
  • - #to_xml + #to_xml - Axlsx::Color + Axlsx::BorderPr
  • - #to_xml + #to_xml - Axlsx::Series + Axlsx::Relationships
  • @@ -2625,9 +2625,9 @@
  • - #type + #type - Axlsx::TableStyleElement + Axlsx::Cell
  • @@ -2641,9 +2641,9 @@
  • - #type + #type - Axlsx::Cell + Axlsx::TableStyleElement
  • @@ -2673,17 +2673,17 @@
  • - validate + #validate - Axlsx::RegexValidator + Axlsx::Package
  • - #validate + validate - Axlsx::Package + Axlsx::RegexValidator
  • @@ -2849,17 +2849,17 @@
  • - #worksheet + #worksheet - Axlsx::Row + Axlsx::Drawing
  • - #worksheet + #worksheet - Axlsx::Drawing + Axlsx::Row
  • diff --git a/doc/top-level-namespace.html b/doc/top-level-namespace.html index 88249615..7ebd7b99 100644 --- a/doc/top-level-namespace.html +++ b/doc/top-level-namespace.html @@ -94,7 +94,7 @@ -- cgit v1.2.3