axlsx 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,7 +6,7 @@ Axlsx: Office Open XML Spreadsheet Generation
6
6
  **Author**: Randy Morgan
7
7
  **Copyright**: 2011
8
8
  **License**: MIT License
9
- **Latest Version**: 1.0.0
9
+ **Latest Version**: 1.0.2
10
10
  **Release Date**: November 20th 2011
11
11
 
12
12
  Synopsis
@@ -26,6 +26,11 @@ Feature List
26
26
 
27
27
  **4. Automatic type support: Axlsx will automatically determine the type of data you are generating. In this release Float, Integer, String and Time types are automatically identified and serialized to your spreadsheet.
28
28
 
29
+ **5. Automatic column widths: Axlsx will automatically determine the appropriate width for your columns based on the content in the worksheet.
30
+
31
+ **6. Support for both 1904 and 1900 epocs configurable in the workbook.
32
+
33
+
29
34
  Installing
30
35
  ----------
31
36
 
@@ -35,19 +40,87 @@ To install Axlsx, use the following command:
35
40
 
36
41
  Usage
37
42
  -----
38
-
39
- Generating a workbook with styles and a chart:
40
- p = Axlsx::Package.new do |package|
41
- package.workbook.add_worksheet do |sheet|
42
- sheet.add_row ["First", "Second", "Third"], :style => Axlsx::STYLE_THIN_BORDER
43
- sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
44
- sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart|
45
- chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
46
- end
47
- end
48
- package.serialize("example1.xlsx")
49
- end
50
-
43
+ Simple Workbook
44
+
45
+ p = Axlsx::Package.new do |package|
46
+ package.workbook.add_worksheet do |sheet|
47
+ sheet.add_row ["First", "Second", "Third"]
48
+ sheet.add_row [1, 2, 3]
49
+ end
50
+ package.serialize("example1.xlsx")
51
+ end
52
+
53
+ Generating A Bar Chart
54
+
55
+ p = Axlsx::Package.new do |package|
56
+ package.workbook.add_worksheet do |sheet|
57
+ sheet.add_row ["First", "Second", "Third"]
58
+ sheet.add_row [1, 2, 3]
59
+ sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart|
60
+ chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
61
+ end
62
+ end
63
+ package.serialize("example1.xlsx")
64
+ end
65
+
66
+ Generating A Pie Chart
67
+
68
+ p = Axlsx::Package.new do |package|
69
+ package.workbook.add_worksheet do |sheet|
70
+ sheet.add_row ["First", "Second", "Third"]
71
+ sheet.add_row [1, 2, 3]
72
+ sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 2: Pie Chart") do |chart|
73
+ chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
74
+ end
75
+ end
76
+ package.serialize("example3.xlsx")
77
+ end
78
+
79
+ Using Custom Styles
80
+
81
+ p = Axlsx::Package.new do |package|
82
+ style_options = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
83
+ header_style = package.workbook.styles.add_style style_options
84
+ package.workbook.add_worksheet do |sheet|
85
+ sheet.add_row ["Text Autowidth", "Second", "Third"], :style => header_style
86
+ sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
87
+ end
88
+ package.serialize("example3.xlsx")
89
+ end
90
+
91
+ Cell Specifc Styles
92
+
93
+ p = Axlsx::Package.new do |package|
94
+
95
+ black_cell_spec = { :bg_color => "FF000000", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
96
+ blue_cell_spec = { :bg_color => "FF0000FF", :fg_color => "FFFFFFFF", :sz=>14, :alignment => { :horizontal=> :center } }
97
+
98
+ black_cell = package.workbook.styles.add_style black_cell_spec
99
+ blue_cell = package.workbook.styles.add_style blue_cell_spec
100
+
101
+ # date1904 support. uncomment the line below if you are working on a mac.
102
+ # package.workbook.date1904 = true
103
+
104
+ package.workbook.add_worksheet do |sheet|
105
+ sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
106
+ sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
107
+ end
108
+ package.serialize("example3.xlsx")
109
+ end
110
+
111
+ Number and Date formatting
112
+ p = Axlsx::Package.new do |package|
113
+ date = package.workbook.styles.add_style :format_code=>"yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER
114
+ padded = package.workbook.styles.add_style :format_code=>"00#", :border => Axlsx::STYLE_THIN_BORDER
115
+ percent = package.workbook.styles.add_style :format_code=>"0%", :border => Axlsx::STYLE_THIN_BORDER
116
+
117
+ package.workbook.add_worksheet do |sheet|
118
+ sheet.add_row
119
+ sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
120
+ sheet.add_row [Time.now, 0.2, 32], :style => [date, percent, padded]
121
+ end
122
+ package.serialize("example5.xlsx")
123
+ end
51
124
 
52
125
  ### Documentation
53
126
  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:
@@ -61,8 +134,11 @@ This gem has 100% test coverage. To execute tests for this gem, simply run rake
61
134
  Changelog
62
135
  ---------
63
136
 
64
- - **October.10.11**: 0.1.0 release
65
-
137
+ - **October.20.11**: 0.1.0 release
138
+ - **October.21.11**: 1.0.3 release
139
+ - Updated documentation
140
+ - altered package to accept a filename string for serialization instead of a File object.
141
+ - Updated specs to conform
66
142
  Copyright
67
143
  ---------
68
144
 
@@ -1,7 +1,7 @@
1
1
  module Axlsx
2
2
 
3
3
  # version
4
- VERSION="1.0.1"
4
+ VERSION="1.0.3"
5
5
 
6
6
  # XML Encoding
7
7
  ENCODING = "UTF-8"
@@ -19,19 +19,15 @@ class TestPackage < Test::Unit::TestCase
19
19
  def test_serialization
20
20
  fname = 'test_serialization.xlsx'
21
21
  assert_nothing_raised do
22
- if File.writable? fname
23
- f = File.open(fname, 'w')
24
- z= @package.serialize(f)
25
-
26
- zf = Zip::ZipFile.open(f.path)
22
+ if File.writable?(fname)
23
+ z= @package.serialize(fname)
24
+ zf = Zip::ZipFile.open(fname)
27
25
  @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }
28
- File.delete(f.path)
29
-
26
+ File.delete(fname)
30
27
  else
31
28
  puts "Skipping write to disk as write permission is not granted to this user"
32
29
  end
33
- end
34
-
30
+ end
35
31
  end
36
32
 
37
33
  def test_validation
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: axlsx
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Randy Morgan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-20 00:00:00 +09:00
18
+ date: 2011-11-21 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -322,8 +322,8 @@ files:
322
322
  - LICENSE
323
323
  - README.md
324
324
  - Rakefile
325
- has_rdoc: yard
326
- homepage: ""
325
+ has_rdoc: axlsx
326
+ homepage: https://rubyforge.org/projects/axlsx/
327
327
  licenses: []
328
328
 
329
329
  post_install_message:
@@ -351,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
351
351
  version: "0"
352
352
  requirements: []
353
353
 
354
- rubyforge_project:
354
+ rubyforge_project: axlsx
355
355
  rubygems_version: 1.3.7
356
356
  signing_key:
357
357
  specification_version: 3