Browse files

Added samples of simple and rich tables.

  • Loading branch information...
1 parent 0a01a57 commit 93aaccf774085603aad7e74b478a152c9e982269 @maximkulkin maximkulkin committed Feb 14, 2010
Showing with 53 additions and 0 deletions.
  1. +33 −0 samples/rich.rb
  2. +20 −0 samples/simple.rb
View
33 samples/rich.rb
@@ -0,0 +1,33 @@
+$LOAD_PATH << File.dirname(__FILE__)+"/../lib"
+
+require 'rubygems'
+require 'spreadsheet'
+
+sheet = Spreadsheet::Builder.new
+sheet.spreadsheet do
+ sheet.table 'Rich time report' do
+ sheet.column :width => '4in'
+ sheet.column :width => '0.5in'
+
+ sheet.header {
+ sheet.row {
+ sheet.cell 'Time report', :span => 2, :style => 'title'
+ }
+ sheet.row {
+ sheet.cell 'Activity', :align => :left
+ sheet.cell 'Hours'
+ }
+ }
+
+ sheet.row {
+ sheet.string_cell 'Developing spreadsheet library'
+ sheet.numeric_cell 80.0
+ }
+ sheet.row {
+ sheet.string_cell 'Writing spreadsheet library documentation'
+ sheet.numeric_cell 2.0
+ }
+ end
+end
+
+File.open('rich_time_report.ods', 'wb') { |f| f.write sheet.content! }
View
20 samples/simple.rb
@@ -0,0 +1,20 @@
+$LOAD_PATH << File.dirname(__FILE__)+"/../lib"
+
+require 'rubygems'
+require 'spreadsheet'
+
+sheet = Spreadsheet::Builder.new
+sheet.spreadsheet do
+ sheet.table 'Simple time report' do
+ sheet.row {
+ sheet.cell 'Developing spreadsheet library'
+ sheet.cell 80.0
+ }
+ sheet.row {
+ sheet.cell 'Writing spreadsheet library documentation'
+ sheet.cell 2.0
+ }
+ end
+end
+
+File.open('simple_time_report.ods', 'wb') { |f| f.write sheet.content! }

0 comments on commit 93aaccf

Please sign in to comment.