From 26a8ad445d84b9dcb9fc36702ec761603a74ee20 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Wed, 21 Mar 2012 01:24:30 +0900 Subject: adding in an option to disable both the require of RMagick and auto-width processing. see Workbook#use_autowidth. Defaults to true for backward compatibility. --- examples/example.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'examples/example.rb') diff --git a/examples/example.rb b/examples/example.rb index df5a401f..d834a51c 100644 --- a/examples/example.rb +++ b/examples/example.rb @@ -144,6 +144,18 @@ wb.add_worksheet(:name => "Bar Chart") do |sheet| end end +##Hide Gridlines in chart +wb.add_worksheet(:name => "Chart With No Gridlines") do |sheet| + sheet.add_row ["A Simple Bar Chart"] + sheet.add_row ["First", "Second", "Third"] + sheet.add_row [1, 2, 3] + sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart| + chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"] + chart.valAxis.gridlines = false + chart.catAxis.gridlines = false + end +end + ##Generating A Pie Chart wb.add_worksheet(:name => "Pie Chart") do |sheet| @@ -201,6 +213,13 @@ wb.add_worksheet(:name => "custom column widths") do |sheet| sheet.column_widths nil, 3 end +##Fit to page printing + +wb.add_worksheet(:name => "fit to page") do |sheet| + sheet.add_row ['this all goes on one page'] + sheet.fit_to_page = true +end + ##Hide Gridlines in worksheet wb.add_worksheet(:name => "No Gridlines") do |sheet| @@ -228,6 +247,15 @@ p.use_shared_strings = true p.serialize("shared_strings_example.xlsx") +##Disabling Autowidth +p = Axlsx::Package.new +p.use_autowidth = false +wb = p.workbook +wb.add_worksheet(:name => "No Magick") do | sheet | + sheet.add_row ['oh look! no autowidth - and no magick loaded in your process'] +end +p.validate.each { |e| puts e.message } +p.serialize("no-use_autowidth.xlsx") -- cgit v1.2.3 From 4889df8a7702c16bee284a9dffa33bdb8abaa55a Mon Sep 17 00:00:00 2001 From: Jurriaan Pruis Date: Sat, 3 Mar 2012 14:52:26 +0100 Subject: Updated example --- examples/example.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'examples/example.rb') diff --git a/examples/example.rb b/examples/example.rb index d834a51c..2191f6a6 100644 --- a/examples/example.rb +++ b/examples/example.rb @@ -206,6 +206,18 @@ wb.add_worksheet(:name => "Auto Filter") do |sheet| sheet.auto_filter = "A2:D5" end +##Tables + +wb.add_worksheet(:name => "Table") do |sheet| + sheet.add_row ["Build Matrix"] + sheet.add_row ["Build", "Duration", "Finished", "Rvm"] + sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"] + 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.add_table "A2:D5", :name => 'Build Matrix' +end + + ##Specifying Column Widths wb.add_worksheet(:name => "custom column widths") do |sheet| @@ -235,7 +247,7 @@ end ##Validate and Serialize -p.validate.each { |e| puts e.message } +#p.validate.each { |e| puts e.message } p.serialize("example.xlsx") s = p.to_stream() -- cgit v1.2.3 From cec81bb125ae4a97d83517e514e9ca9ee387398f Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Wed, 21 Mar 2012 23:25:12 +0900 Subject: @jurriaan is a rockstar. --- examples/example.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/example.rb') diff --git a/examples/example.rb b/examples/example.rb index 2191f6a6..85028559 100644 --- a/examples/example.rb +++ b/examples/example.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby -w -s # -*- coding: utf-8 -*- -require 'axlsx.rb' +$:.unshift "#{File.dirname(__FILE__)}/../lib" +require 'axlsx' p = Axlsx::Package.new wb = p.workbook @@ -39,7 +40,7 @@ end ##Add an Image wb.add_worksheet(:name => "Images") do |sheet| - img = File.expand_path('examples/image1.jpeg') + img = File.expand_path('../image1.jpeg', __FILE__) sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image| image.width=720 image.height=666 @@ -50,7 +51,7 @@ end ##Add an Image with a hyperlink wb.add_worksheet(:name => "Image with Hyperlink") do |sheet| - img = File.expand_path('examples/image1.jpeg') + img = File.expand_path('../image1.jpeg', __FILE__) sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image| image.width=720 image.height=666 -- cgit v1.2.3 From 3f4068f423d144513c33b2c1e94ee8a78ad38813 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Wed, 21 Mar 2012 23:39:54 +0900 Subject: brining the table example back in. Still frustrated that this tosses up 'unsupported' errors in mac. --- examples/example.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'examples/example.rb') diff --git a/examples/example.rb b/examples/example.rb index 85028559..2b4f795b 100644 --- a/examples/example.rb +++ b/examples/example.rb @@ -209,14 +209,14 @@ end ##Tables -wb.add_worksheet(:name => "Table") do |sheet| - sheet.add_row ["Build Matrix"] - sheet.add_row ["Build", "Duration", "Finished", "Rvm"] - sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"] - 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.add_table "A2:D5", :name => 'Build Matrix' -end + wb.add_worksheet(:name => "Table") do |sheet| + sheet.add_row ["Build Matrix"] + sheet.add_row ["Build", "Duration", "Finished", "Rvm"] + sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"] + 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.add_table "A2:D5", :name => 'Build Matrix' + end ##Specifying Column Widths -- cgit v1.2.3 From 7881ee37e08d7768f8ba7c9270f2f07ea8b78cd0 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Fri, 23 Mar 2012 01:15:37 +0900 Subject: readme and examples updates. --- README.md | 22 ++++++++++++---------- examples/example.rb | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'examples/example.rb') diff --git a/README.md b/README.md index e46be3dc..6a466d34 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Synopsis -------- Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language. -With Axlsx you can create excel worksheets with charts, images (with links), automated and fixed column widths, customizable styles, functions, merged cells, auto filters, file and stream serialization as well as full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification. +With Axlsx you can create excel worksheets with charts, images (with links), automated and fixed column widths, customized styles, functions, merged cells, auto filters, file and stream serialization as well as full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification. If you are working in rails, or with active record see: http://github.com/randym/acts_as_xlsx @@ -35,12 +35,12 @@ There are guides for using axlsx and acts_as_xlsx here: Help Wanted ----------- -I'd really like to get rid of the depenency on RMagick in this gem. RMagic is being used to calculate the column widths in a worksheet based on the content the user specified. If there happens to be anyone out there with the background and c skills to write an extenstion that can determine the width of a single character rendered with a specific font at a specific font size please give me a shout. +I'd really like to get rid of the dependency on RMagick in this gem. RMagic is being used to calculate the column widths in a worksheet based on the content the user specified. If there happens to be anyone out there with the background and c skills to write an extension that can determine the width of a single character rendered with a specific font at a specific font size please give me a shout. Feature List ------------ -**1. Author xlsx documents: Axlsx is made to let you easily and quickly generate profesional xlsx based reports that can be validated before serialiation. +**1. Author xlsx documents: Axlsx is made to let you easily and quickly generate professional xlsx based reports that can be validated before serialization. **2. Generate 3D Pie, Line and Bar Charts: With Axlsx chart generation and management is as easy as a few lines of code. You can build charts based off data in your worksheet or generate charts without any data in your sheet at all. @@ -54,7 +54,7 @@ Feature List **7. Add jpg, gif and png images to worksheets with hyperlinks -**8. Reference cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "Sheett1!A3:B4" style references +**8. Reference cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "Sheet1!A3:B4" style references **9. Cell level style overrides for default and customized style objects @@ -309,7 +309,7 @@ To install Axlsx, use the following command: p.validate.each { |e| puts e.message } p.serialize("example.xlsx") - # alternatively, serilaize to StringIO + # alternatively, serialize to StringIO s = p.to_stream() File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) } @@ -341,7 +341,7 @@ This gem is 100% documented with YARD, an exceptional documentation library. To ------ This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory. -#Changelog +#Change log --------- - ** March.??.12**: 1.0.19 release - bugfix patch name_to_indecies to properly handle extended ranges. @@ -350,8 +350,10 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem, - Added Fit to Page printing - added support for turning off gridlines in charts. - added support for turning off gridlines in worksheet. - - bugfix some apps like libraoffice require apply[x] attributes to be true. applyAlignment is not properly set. + - bugfix some apps like libraoffice require apply[x] attributes to be true. applyAlignment is now properly set. - added option to *not* use RMagick - and default all assigned columns to the excel default of 8.43 + - added border style specification to styles#add_style - now you can pass in :border => {:style => :thin, :color =>"0000FF"} instead of creating a border object and border parts manually each time. + - Support for tables added in - Note: Pre 2011 versions of Mac office do not support this feature. - ** March.5.12**: 1.0.18 release https://github.com/randym/axlsx/compare/1.0.17...1.0.18 @@ -368,13 +370,13 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem, - Added in support for serializing to StringIO - Added in support for using shared strings table. This makes most of the features in axlsx interoperable with iWorks Numbers - Added in support for fixed column_widths - - Removed unneded depenencies on activesupport and i18n + - Removed unneeded dependencies on active-support and i18n - ** February.2.12**: 1.0.16 release https://github.com/randym/axlsx/compare/1.0.15...1.0.16 - Bug fix for schema file locations when validating in rails - Added hyperlink to images - - date1904 now automatically set in bsd and mac environments + - date1904 now automatically set in BSD and mac environments - removed whitespace/indentation from xml outputs - col_style now skips rows that do not contain cells at the column index @@ -397,7 +399,7 @@ Please see the {file:CHANGELOG.md} document for past release information. [jurriaan](https://github.com/jurriaan) - for showing there is more than one way to skin a cat, and work with rows while you are at it. -[joekain](https://github.com/joekain) - for keeping our refereneces working even in the double digits! +[joekain](https://github.com/joekain) - for keeping our references working even in the double digits! #Copyright and License ---------- diff --git a/examples/example.rb b/examples/example.rb index 2b4f795b..36fe6b37 100644 --- a/examples/example.rb +++ b/examples/example.rb @@ -24,6 +24,19 @@ wb.styles do |s| end end +#Using Custom Border Styles + +wb.styles do |s| + red_border = s.add_style :border => {:style=>:thin, :color =>"FFFF0000"} + blue_border = s.add_style :border => {:style=>:thin, :color =>"FF0000FF"} + + wb.add_worksheet(:name => "Custom Borders") do |sheet| + sheet.add_row ["wrap", "me", "Up in Red"], :style => red_border + sheet.add_row [1, 2, 3], :style => blue_border + end +end + + ##Using Custom Formatting and date1904 require 'date' wb.styles do |s| @@ -37,6 +50,7 @@ wb.styles do |s| end end + ##Add an Image wb.add_worksheet(:name => "Images") do |sheet| -- cgit v1.2.3 From cd6fb747bbf2915f92f1fb0169e7f54d87aa1915 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Fri, 23 Mar 2012 23:51:59 +0900 Subject: Explicitly state $LOAD_PATH in example --- examples/example.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/example.rb') diff --git a/examples/example.rb b/examples/example.rb index 36fe6b37..2c0f5fc1 100644 --- a/examples/example.rb +++ b/examples/example.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -w -s # -*- coding: utf-8 -*- -$:.unshift "#{File.dirname(__FILE__)}/../lib" +$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" require 'axlsx' p = Axlsx::Package.new -- cgit v1.2.3