rubyXL 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,13 +6,61 @@
6
6
  == To Use:
7
7
  require 'rubyXL' #assuming rubygems is already required
8
8
 
9
- === Parsing
9
+ === Parsing an existing workbook
10
10
  workbook = RubyXL::Parser.parse("path/to/Excel/file.xlsx")
11
11
 
12
12
 
13
- === Creating
13
+ === Creating a new Workbook
14
14
  workbook = RubyXL::Workbook.new
15
15
 
16
+ === Accessing
17
+
18
+ ==== Accessing a Worksheet
19
+ workbook.worksheets[0] #returns first worksheet
20
+ workbook[0] #returns first worksheet
21
+
22
+ ==== Accessing a Row (Array of Cells)
23
+ workbook[0].sheet_data[0] #returns first row in first worksheet
24
+ workbook[0][0] #returns first row in first worksheet
25
+
26
+ ==== Accessing a Cell
27
+ workbook[0].sheet_data[0][0] #returns A1 in first worksheet
28
+ workbook[0][0][0] #returns A1 in first worksheet
29
+
30
+ ==== Accessing Cell properties
31
+ workbook[0][0][0].is_struckthrough() #returns if A1 is struckthrough, other boolean properties have same syntax
32
+ workbook[0][0][0].font_name #returns font name for A1
33
+ workbook[0][0][0].font_size #returns font size for A1
34
+ workbook[0][0][0].font_color #returns font color for A1
35
+ workbook[0][0][0].fill_color #returns fill color for A1
36
+ workbook[0][0][0].horizontal_alignment #returns horizontal alignment for A1 (or nil if it does not exist)
37
+ workbook[0][0][0].vertical_alignment #returns vertical alignment for A1 (or nil if it does not exist)
38
+ workbook[0][0][0].border_top #returns type of border on top of A1 (nil if none exists), other directions have same syntax
39
+
40
+ ==== Accessing row properties
41
+ workbook[0].get_row_fill(0) #returns fill color for first row
42
+ workbook[0].get_row_font_name(0) #returns font name for first row
43
+ workbook[0].get_row_font_size(0) #returns font size for first row
44
+ workbook[0].get_row_font_color(0) #returns font color for first row
45
+ workbook[0].is_row_underlined(0) #returns if first row is italicized, other boolean properties have same syntax
46
+ workbook[0].get_row_height(0) #returns height of first row
47
+ workbook[0].get_row_horizontal_alignment(0) #returns horizontal alignment of first row (nil if none exists)
48
+ workbook[0].get_row_vertical_alignment(0) #returns vertical alignment of first row (nil if none exists)
49
+ workbook[0].get_row_border_right(0) #returns weight of right border of first row (nil if none exists), other directions have the same syntax
50
+
51
+ ==== Accessing column properties
52
+ workbook[0].get_column_fill(0) #returns fill color for first column
53
+ workbook[0].get_column_font_name(0) #returns font name for first column
54
+ workbook[0].get_column_font_size(0) #returns font size for first column
55
+ workbook[0].get_column_font_color(0) #returns font color for first column
56
+ workbook[0].is_column_underlined(0) #returns if first column is italicized, other boolean properties have same syntax
57
+ workbook[0].get_column_height(0) #returns height of first column
58
+ workbook[0].get_column_horizontal_alignment(0) #returns horizontal alignment of first column (nil if none exists)
59
+ workbook[0].get_column_vertical_alignment(0) #returns vertical alignment of first column (nil if none exists)
60
+ workbook[0].get_column_border_right(0) #returns weight of right border of first column (nil if none exists), other directions have the same syntax
61
+
62
+ ==== Table identification
63
+ #get table
16
64
 
17
65
  === Modifying
18
66
 
@@ -21,23 +69,71 @@
21
69
 
22
70
  ==== Adding Cells
23
71
  workbook.worksheets[0].add_cell(0,0,'A1') #sets A1 to string "A1"
24
- workbook.worksheets[0].add_cell(0,1,'','A1') #sets A2 to value of A1
72
+ workbook.worksheets[0].add_cell(0,1,'','A1') #sets B1 to value of A1
73
+
74
+ workbook.worksheets[0].add_cell_obj(Cell.new(1,0,'blah')) #sets A2 to 'blah'
75
+
25
76
 
26
77
  ==== Changing Fonts
27
78
  workbook.worksheets[0].sheet_data[0][0].change_font_bold(true) #sets A1 to bold
28
79
  workbook.worksheets[0].change_row_font_italics(0,true) #makes first row italicized
29
- workbook.worksheets[0].change_column_font_name(0,'Verdana')
80
+ workbook.worksheets[0].change_column_font_name(0,'Courier') #makes first column have font Courier
30
81
 
31
82
  ==== Changing Fills
32
- #code here
83
+ workbook.worksheets[0].sheet_data[0][0].change_fill('0ba53d') #sets A1 to have fill #0ba53d
84
+ workbook.worksheets[0].change_row_fill(0, '0ba53d') #sets first row to have fill #0ba53d
85
+ workbook.worksheets[0].change_column_fill(0, '0ba53d') #sets first column to have fill #0ba53d
86
+
87
+ ==== Changing Borders
88
+ # Possible weights: hairline, thin, medium, thick
89
+ # Possible "directions": top, bottom, left, right, diagonal
90
+ workbook.worksheets[0].sheet_data[0][0].change_border_top('thin') #sets A1 to have a top, thin border
91
+ workbook.worksheets[0].change_row_border_left(0, 'hairline') #sets first row to have a left, hairline border
92
+ workbook.worksheets[0].change_column_border_diagonal(0, 'medium') #sets first column to have diagonal, medium border
93
+
94
+ ==== Changing Alignment
95
+ ===== Horizontal
96
+ center, distributed, justify, left, right
97
+ workbook.worksheets[0].sheet_data[0][0].change_horizontal_alignment('center') #sets A1 to be centered
98
+ workbook.worksheets[0].change_row_horizontal_alignment(0,'justify') #sets first row to be justified
99
+ workbook.worksheets[0].change_column_horizontal_alignment(0,'right'), #sets first column to be right-aligned
100
+
101
+ ===== Vertical
102
+ bottom, center, distributed, top
103
+ workbook.worksheets[0].sheet_data[0][0].change_vertical_alignment('bottom') #sets A1 to be bottom aligned
104
+ workbook.worksheets[0].change_row_vertical_alignment(0,'distributed') #sets first row to be distributed vertically
105
+ workbook.worksheets[0].change_column_vertical_alignment(0,'top') #sets first column to be top aligned
106
+
107
+ ==== Changing Row Height
108
+ workbook.worksheets[0].change_row_height(0,30) #sets first row to be of height 30
109
+
110
+ ==== Changing Column Width
111
+ workbook.worksheets[0].change_column_width(0,30) #sets first column to be of width 30
33
112
 
34
113
  ==== Merging Cells
35
- #code here
114
+ workbook.worksheets[0].merge_cells(0,0,1,1) #merges A1:B2
115
+
116
+ ==== Insert Row
117
+ #insert row
118
+
119
+ ==== Insert Column
120
+ #insert column
121
+
122
+ ==== Delete Row
123
+ #delete row
124
+
125
+ ==== Delete Column
126
+ #delete column
127
+
36
128
 
37
129
  === Writing
38
130
  workbook.write("path/to/desired/Excel/file.xlsx")
39
131
 
40
132
 
133
+ === Miscellaneous
134
+ Cell.convert_to_cell(0,0) == 'A1' #converts row and column index to Excel-style index
135
+ Parser.convert_to_index('A1') == [0,0] #converts Excel-style index to row and column index
136
+
41
137
  == For more information
42
138
  Take a look at the files in spec/lib/ for rspecs on most methods
43
139
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -126,7 +126,7 @@ module Writer
126
126
  xml.c('r'=>Cell.convert_to_cell(i,j),
127
127
  's'=>dat.style_index.to_s, 't'=>dat.datatype) {
128
128
  unless dat.formula.nil?
129
- if dat.formula_attributes.empty?
129
+ if dat.formula_attributes.nil? || dat.formula_attributes.empty?
130
130
  xml.f dat.formula.to_s
131
131
  else
132
132
  xml.f('t'=>dat.formula_attributes['t'].to_s, 'ref'=>dat.formula_attributes['ref'], 'si'=>dat.formula_attributes['si']).nokogiri dat.formula
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubyXL}
8
- s.version = "1.1.0"
8
+ s.version = "1.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Vivek Bhagwat"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyXL
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vivek Bhagwat