rubyXL 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -0,0 +1,2 @@
1
+ To install:
2
+ gem install rubyXL
data/README.rdoc CHANGED
@@ -1,6 +1,28 @@
1
1
  = rubyXL
2
2
 
3
- Description goes here.
3
+ == To Install:
4
+ gem install rubyXL
5
+
6
+ == To Use:
7
+ require 'rubyXL' #assuming rubygems is already required
8
+
9
+ === Parsing
10
+ workbook = RubyXL::Parser.parse("path/to/Excel/file.xlsx")
11
+
12
+ === Creating
13
+ workbook = RubyXL::Workbook.new
14
+ workbook.worksheets[0].add_cell(0,0,'A1') #sets A1 to string "A1"
15
+ workbook.worksheets[0].add_cell(0,1,'','A1') #sets A2 to value of A1
16
+
17
+ === Modifying
18
+ workbook.worksheets[0].sheet_data[0][0].change_font_bold(true) #sets A1 to bold
19
+ workbook.worksheets[0].change_row_font_italics(0,true) #makes first row italicized
20
+
21
+ === Writing
22
+ workbook.write("path/to/desired/Excel/file.xlsx")
23
+
24
+ == For more information
25
+ Take a look at the files in spec/lib/ for rspecs on most methods
4
26
 
5
27
  == Contributing to rubyXL
6
28
 
data/Rakefile CHANGED
@@ -15,10 +15,10 @@ require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
17
  gem.name = "rubyXL"
18
- gem.homepage = "http://github.com/vivekbhagwat/rubyXL"
18
+ gem.homepage = "http://github.com/gilt/rubyXL"
19
19
  gem.license = "MIT"
20
- gem.summary = %Q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx) Documents}
21
- gem.description = %Q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx) Documents}
20
+ gem.summary = %Q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
21
+ gem.description = %Q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
22
22
  gem.email = "bhagwat.vivek@gmail.com"
23
23
  gem.authors = ["Vivek Bhagwat"]
24
24
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.0.7
data/lib/rubyXL.rb CHANGED
@@ -4,6 +4,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'private_class'))
4
4
  require File.expand_path(File.join(File.dirname(__FILE__),'worksheet'))
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'cell'))
6
6
  require File.expand_path(File.join(File.dirname(__FILE__),'parser'))
7
+ require File.expand_path(File.join(File.dirname(__FILE__),'color'))
7
8
 
8
9
  module RubyXL
9
10
  end
data/lib/worksheet.rb CHANGED
@@ -977,7 +977,7 @@ class Worksheet < PrivateClass
977
977
  end
978
978
 
979
979
  @row_styles[(row+1).to_s][:style] =
980
- modify_font(@workbook,Integer(@row_styles[(row+1).to_s][:style]))
980
+ modify_font(@workbook,(@row_styles[(row+1).to_s][:style]).to_i)
981
981
 
982
982
  if @sheet_data[row].nil?
983
983
  @sheet_data[row] = []
@@ -280,10 +280,10 @@ module Writer
280
280
  'fillId'=>fill_id_corrector[xf[:fillId].to_s].to_s,
281
281
  'borderId'=>border_id_corrector[xf[:borderId].to_s].to_s,
282
282
  'xfId'=>xf[:xfId].to_s,
283
- 'applyFont'=>Integer(xf[:applyFont]).to_s, #0 if nil
284
- 'applyFill'=>Integer(xf[:applyFill]).to_s,
285
- 'applyAlignment'=>Integer(xf[:applyAlignment]).to_s,
286
- 'applyNumberFormat'=>Integer(xf[:applyNumberFormat]).to_s) {
283
+ 'applyFont'=>xf[:applyFont].to_i.to_s, #0 if nil
284
+ 'applyFill'=>xf[:applyFill].to_i.to_s,
285
+ 'applyAlignment'=>xf[:applyAlignment].to_i.to_s,
286
+ 'applyNumberFormat'=>xf[:applyNumberFormat].to_i.to_s) {
287
287
  unless xf_obj.is_a?Array
288
288
  unless xf_obj[:alignment].nil?
289
289
  xml.alignment('horizontal'=>xf_obj[:alignment][:attributes][:horizontal].to_s,
@@ -1,7 +1,4 @@
1
- # require File.expand_path(File.join(File.dirname(__FILE__),'workbook'))
2
- # require File.expand_path(File.join(File.dirname(__FILE__),'worksheet'))
3
- # require File.expand_path(File.join(File.dirname(__FILE__),'cell'))
4
- # require File.expand_path(File.join(File.dirname(__FILE__),'color'))
1
+ # coding: utf-8
5
2
  require 'rubygems'
6
3
  require 'nokogiri'
7
4
 
data/rubyXL.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubyXL}
8
- s.version = "1.0.6"
8
+ s.version = "1.0.7"
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"]
12
- s.date = %q{2011-08-01}
13
- s.description = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx) Documents}
12
+ s.date = %q{2011-08-02}
13
+ s.description = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
14
14
  s.email = %q{bhagwat.vivek@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
@@ -32,17 +32,6 @@ Gem::Specification.new do |s|
32
32
  "lib/parser.rb",
33
33
  "lib/private_class.rb",
34
34
  "lib/rubyXL.rb",
35
- "lib/test.html",
36
- "lib/tests/test.rb",
37
- "lib/tests/test10.rb",
38
- "lib/tests/test2.rb",
39
- "lib/tests/test3.rb",
40
- "lib/tests/test4.rb",
41
- "lib/tests/test5.rb",
42
- "lib/tests/test6.rb",
43
- "lib/tests/test7.rb",
44
- "lib/tests/test8.rb",
45
- "lib/tests/test9.rb",
46
35
  "lib/workbook.rb",
47
36
  "lib/worksheet.rb",
48
37
  "lib/writer/app_writer.rb",
@@ -65,11 +54,11 @@ Gem::Specification.new do |s|
65
54
  "spec/lib/workbook_spec.rb",
66
55
  "spec/lib/worksheet_spec.rb"
67
56
  ]
68
- s.homepage = %q{http://github.com/vivekbhagwat/rubyXL}
57
+ s.homepage = %q{http://github.com/gilt/rubyXL}
69
58
  s.licenses = ["MIT"]
70
59
  s.require_paths = ["lib"]
71
60
  s.rubygems_version = %q{1.3.7}
72
- s.summary = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx) Documents}
61
+ s.summary = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
73
62
 
74
63
  if s.respond_to? :specification_version then
75
64
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 6
10
- version: 1.0.6
9
+ - 7
10
+ version: 1.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vivek Bhagwat
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-01 00:00:00 -04:00
18
+ date: 2011-08-02 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- prerelease: false
22
+ type: :development
23
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
@@ -29,11 +29,11 @@ dependencies:
29
29
  segments:
30
30
  - 0
31
31
  version: "0"
32
+ prerelease: false
32
33
  name: shoulda
33
34
  requirement: *id001
34
- type: :development
35
35
  - !ruby/object:Gem::Dependency
36
- prerelease: false
36
+ type: :development
37
37
  version_requirements: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
39
39
  requirements:
@@ -45,11 +45,11 @@ dependencies:
45
45
  - 0
46
46
  - 0
47
47
  version: 1.0.0
48
+ prerelease: false
48
49
  name: bundler
49
50
  requirement: *id002
50
- type: :development
51
51
  - !ruby/object:Gem::Dependency
52
- prerelease: false
52
+ type: :development
53
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
@@ -61,11 +61,11 @@ dependencies:
61
61
  - 6
62
62
  - 0
63
63
  version: 1.6.0
64
+ prerelease: false
64
65
  name: jeweler
65
66
  requirement: *id003
66
- type: :development
67
67
  - !ruby/object:Gem::Dependency
68
- prerelease: false
68
+ type: :development
69
69
  version_requirements: &id004 !ruby/object:Gem::Requirement
70
70
  none: false
71
71
  requirements:
@@ -75,11 +75,11 @@ dependencies:
75
75
  segments:
76
76
  - 0
77
77
  version: "0"
78
+ prerelease: false
78
79
  name: rcov
79
80
  requirement: *id004
80
- type: :development
81
81
  - !ruby/object:Gem::Dependency
82
- prerelease: false
82
+ type: :development
83
83
  version_requirements: &id005 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
@@ -91,11 +91,11 @@ dependencies:
91
91
  - 4
92
92
  - 4
93
93
  version: 1.4.4
94
+ prerelease: false
94
95
  name: nokogiri
95
96
  requirement: *id005
96
- type: :development
97
97
  - !ruby/object:Gem::Dependency
98
- prerelease: false
98
+ type: :development
99
99
  version_requirements: &id006 !ruby/object:Gem::Requirement
100
100
  none: false
101
101
  requirements:
@@ -107,11 +107,11 @@ dependencies:
107
107
  - 9
108
108
  - 4
109
109
  version: 0.9.4
110
+ prerelease: false
110
111
  name: rubyzip
111
112
  requirement: *id006
112
- type: :development
113
113
  - !ruby/object:Gem::Dependency
114
- prerelease: false
114
+ type: :development
115
115
  version_requirements: &id007 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
@@ -123,10 +123,10 @@ dependencies:
123
123
  - 3
124
124
  - 4
125
125
  version: 1.3.4
126
+ prerelease: false
126
127
  name: rspec
127
128
  requirement: *id007
128
- type: :development
129
- description: rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx) Documents
129
+ description: rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents
130
130
  email: bhagwat.vivek@gmail.com
131
131
  executables: []
132
132
 
@@ -151,17 +151,6 @@ files:
151
151
  - lib/parser.rb
152
152
  - lib/private_class.rb
153
153
  - lib/rubyXL.rb
154
- - lib/test.html
155
- - lib/tests/test.rb
156
- - lib/tests/test10.rb
157
- - lib/tests/test2.rb
158
- - lib/tests/test3.rb
159
- - lib/tests/test4.rb
160
- - lib/tests/test5.rb
161
- - lib/tests/test6.rb
162
- - lib/tests/test7.rb
163
- - lib/tests/test8.rb
164
- - lib/tests/test9.rb
165
154
  - lib/workbook.rb
166
155
  - lib/worksheet.rb
167
156
  - lib/writer/app_writer.rb
@@ -184,7 +173,7 @@ files:
184
173
  - spec/lib/workbook_spec.rb
185
174
  - spec/lib/worksheet_spec.rb
186
175
  has_rdoc: true
187
- homepage: http://github.com/vivekbhagwat/rubyXL
176
+ homepage: http://github.com/gilt/rubyXL
188
177
  licenses:
189
178
  - MIT
190
179
  post_install_message:
@@ -216,6 +205,6 @@ rubyforge_project:
216
205
  rubygems_version: 1.3.7
217
206
  signing_key:
218
207
  specification_version: 3
219
- summary: rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx) Documents
208
+ summary: rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents
220
209
  test_files: []
221
210
 
data/lib/test.html DELETED
@@ -1 +0,0 @@
1
- <!doctype html><html><head></head><body><h1 style='text-align:center'>/Users/vbhagwat/Documents/excelTestFiles/threeSheetWorkbook/threeSheetWorkbook.xlsx</h1><h2>Sheet1</h2><table border="1"><tr><td style="color:#000000; background-color:#ffffff">1</td></tr></table><br /><br /><h2>ASD</h2><table border="1"><tr><td style="color:#000000; background-color:#ffffff">1</td><td style="color:#000000; background-color:#ffffff">2</td><td style="color:#000000; background-color:#ffffff">3</td></tr></table><br /><br /><h2>asdf</h2><table border="1"><tr><td style="color:#000000; background-color:#ffffff">1</td><td>----</td><td>----</td></tr><tr><td>----</td><td style="color:#000000; background-color:#ffffff">2</td><td>----</td></tr><tr><td>----</td><td>----</td><td style="color:#000000; background-color:#ffffff">3</td></tr></table><br /><br /></body></html>
data/lib/tests/test.rb DELETED
@@ -1,110 +0,0 @@
1
- require '../rubyXL'
2
- require 'rubygems'
3
- require 'FileUtils'
4
- require 'nokogiri'
5
-
6
-
7
- module RubyXL
8
- #writes blank_workbook to .xlsx
9
-
10
- # file_p ath = "/Users/vbhagwat/Documents/excelTestFiles/styledWorkbook/styledWorkbook.xlsx"
11
- # file_path = "/Users/vbhagwat/Documents/excelTestFiles/smallFormulaWorkbook2/smallFormulaWorkbook2.xlsx"
12
- # file_path = "/Users/vbhagwat/Documents/excelTestFiles/threeSheetWorkbook/threeSheetWorkbook.xlsx"
13
- # file_path = "/Users/vbhagwat/Documents/excelTestFiles/numWorkbook2/numWorkbook2.xlsx"
14
- file_path = "/Users/vbhagwat/Documents/excelTestFiles/blankWorkbook/blankWorkbook.xlsx"
15
- # file_path = '/Users/vbhagwat/Desktop/test2/Archive.xlsx'
16
- # file_path = "/Users/vbhagwat/Desktop/5-1_5-20.xlsx"
17
-
18
- # puts 'begin parsing ' + file_path
19
- # wb = Parser.parse(file_path)
20
- # puts 'completed parsing ' + file_path
21
-
22
- # def initialize(worksheets,filepath,creator=nil,modifier=nil,created_at=nil,modified_at=nil, company=nil, application=nil,appversion=nil,
23
-
24
-
25
- dirpath = '/Users/vbhagwat/Documents/excelTestFiles'
26
- wb = Workbook.new(
27
- [], #worksheets
28
- file_path, #filepath
29
- 'Vivek Bhagwat', #creator
30
- 'Vivek Bhagwat', #modifier
31
- '2011-05-16T15:41:00Z', #created_at
32
- 'Gilt Groupe', #company
33
- 'Microsoft Macintosh Excel', #application
34
- '12.0000')
35
- wb.worksheets = [Worksheet.new(wb,'Sheet1',[[nil]])]
36
- wb2 = Workbook.new(
37
- [], #worksheets
38
- file_path, #filepath
39
- 'Vivek Bhagwat', #creator
40
- 'Vivek Bhagwat', #modifier
41
- '2011-05-16T15:41:00Z', #created_at
42
- 'Gilt Groupe', #company
43
- 'Microsoft Macintosh Excel', #application
44
- '12.0000')
45
- wb.worksheets = [Worksheet.new('Sheet1')]
46
-
47
- wb2[0].sheet_data = [[Cell.new(wb2[0],0,0,'6/8/2011'), Cell.new(wb2[0],0,1,'test2')]]
48
-
49
- # wb = Parser.parse(file_path)
50
- file_path = '/Users/vbhagwat/Desktop/test2/Output/blank.xlsx'
51
- puts 'begin writing ' + file_path
52
- p wb
53
- wb.write(file_path)
54
- puts 'completed writing ' + file_path
55
-
56
- # file_path = "/Users/vbhagwat/Documents/excelTestFiles/twoSheetWorkbook/twoSheetWorkbook.xlsx"
57
- file_path = "/Users/vbhagwat/Documents/excelTestFiles/styledWorkbook7/styledWorkbook7.xlsx"
58
-
59
- wb3 = Parser.parse(file_path)
60
- wb3.write('/Users/vbhagwat/Desktop/test2/Output/small_before.xlsx')
61
-
62
-
63
- # file_path = "/Users/vbhagwat/Desktop/5-1_5-20.xlsx"
64
- wb2 = Parser.parse(file_path)
65
- file_path = '/Users/vbhagwat/Desktop/test2/Output/small.xlsx'
66
-
67
- wb2.worksheets[0].change_row_font_name(1,'Courier') #0 indexed.
68
- wb2.worksheets[0].change_row_font_size(1,30) #0 indexed.
69
- cell = wb2.worksheets[0].add_cell(0,0,'A1')
70
- wb2.worksheets[0].change_row_fill(0,'00FF00')
71
- wb2.worksheets[0].add_cell(0,1,'B1')
72
-
73
- wb2.worksheets[0].change_column_fill(0,'FFFF00')
74
- wb2.worksheets[0].change_column_font_size(0,20)
75
- wb2.worksheets[0].change_column_width(0,30)
76
- wb2.worksheets[0].change_row_height(2,100)
77
-
78
-
79
- p wb2.worksheets[0].row_styles
80
-
81
- wb2.worksheets[0].insert_row(0)
82
-
83
- wb2.worksheets[0].change_column_width(3,50)
84
-
85
- wb2.worksheets[0].insert_column(0)
86
-
87
- p wb2.worksheets[0].row_styles
88
- # raise 'end'
89
-
90
- puts 'begin writing ' + file_path
91
- # p wb2
92
- wb2[0].change_row_font_color(2,'ffffff')
93
-
94
- wb2.write(file_path)
95
- puts 'completed writing ' + file_path
96
-
97
- # app = Writer::AppWriter.new(dirpath, wb)
98
- # p app.hash
99
- # two = app.hash
100
- # puts ''
101
- # app.write()
102
- #
103
- #
104
- # str = XmlSimple.xml_out(two)
105
- # str = str.gsub(/opt/,'Properties')
106
- # puts '..'
107
- # p str
108
-
109
-
110
- end
data/lib/tests/test10.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'rubygems'
2
- require 'rubyXL'
3
-
4
- @workbook = RubyXL::Workbook.new
5
- @worksheet = RubyXL::Worksheet.new(@workbook)
6
- @workbook.worksheets[0] = @worksheet
7
- (0..10).each do |i|
8
- (0..10).each do |j|
9
- @worksheet.add_cell(i, j, "#{i}:#{j}")
10
- end
11
- end
12
-
13
- @worksheet.change_column_font_color(0,'ff0000')
14
- @worksheet.change_column_font_size(0,"30")
15
-
16
- @workbook.write('/Users/vbhagwat/Desktop/test2/Output/test10.xlsx')
data/lib/tests/test2.rb DELETED
@@ -1,118 +0,0 @@
1
- require 'rubygems'
2
- require 'xmlsimple'
3
- require 'zip/zip'
4
- require 'FileUtils'
5
- require 'zip/zipfilesystem'
6
- require 'zip'
7
-
8
- module RubyXL
9
- #takes /Users/vbhagwat/Desktop/test1/Workbook1.xlsx
10
- #copies, unzips, zips
11
-
12
- # #takes path of directoy to be compressed
13
- # #writes zip in that directory
14
- # def compress(path)
15
- # puts 'path'
16
- # p path
17
- # path.sub!(%r[/$],'')
18
- # p path
19
- # archive = File.join(path,File.basename(path))+'.zip'
20
- # puts 'archive'
21
- # p archive
22
- # FileUtils.rm archive, :force=>true
23
- # Zip::ZipFile.open(archive, 'w') do |zipfile|
24
- # Dir["#{path}/**/**"].reject{|f|f==archive}.each do |file|
25
- # puts 'here'
26
- # p file.to_s()
27
- # temp = file
28
- # p temp.sub(path+'/','')
29
- # zipfile.add(file.sub(path+'/',''),file)
30
- # end
31
- # end
32
- # end
33
- #
34
- # #unzips file
35
- # def unzip(zipPath,zipDirPath)
36
- # Zip::ZipFile.open(zipPath) { |zip_file|
37
- # zip_file.each { |f|
38
- # fpath = File.join(zipDirPath, f.name)
39
- # FileUtils.mkdir_p(File.dirname(fpath))
40
- # zip_file.extract(f, fpath) unless File.exist?(fpath)
41
- # }
42
- # }
43
- # end
44
-
45
- z = MyZip.new
46
-
47
-
48
- dirPath = '/Users/vbhagwat/Desktop/test2/'
49
- filePath = dirPath + 'Workbook1.xlsx'
50
- zipDirPath = dirPath+'Workbook1/'
51
- zipPath = zipDirPath + 'Workbook1.zip'
52
-
53
- FileUtils.mkdir_p(dirPath+'Workbook1')
54
- FileUtils.cp(filePath,zipPath)
55
-
56
- z.unzip(zipPath,zipDirPath)
57
- #TODO test if xml_in then xml_out corrupts it
58
- # FileUtils.rm(zipPath) #removes zip file created
59
-
60
- #commented out because i copy this anyway
61
- # contents = XmlSimple.xml_in(zipDirPath + '[Content_Types].xml')
62
- # contents = XmlSimple.xml_out(contents).gsub(/<\/?opt>/,'')
63
- # file = File.new(zipDirPath+'[Content_Types].xml', 'w+')
64
- # file.write(contents)
65
- # file.close
66
-
67
- # contents = XmlSimple.xml_in(zipDirPath+'docProps/app.xml')
68
- # contents = XmlSimple.xml_out(contents).gsub(/<\/?opt>/,'')
69
- # file = File.new(zipDirPath+'docProps/app.xml', 'w+')
70
- # file.write(contents)
71
- # file.close
72
- #
73
- # contents = XmlSimple.xml_in(zipDirPath+'docProps/core.xml')
74
- # contents = XmlSimple.xml_out(contents).gsub(/<\/?opt>/,'')
75
- # file = File.new(zipDirPath+'docProps/core.xml', 'w+')
76
- # file.write(contents)
77
- # file.close
78
- #
79
- # contents = XmlSimple.xml_in(zipDirPath+'xl/_rels/workbook.xml.rels')
80
- # contents = XmlSimple.xml_out(contents).gsub(/<\/?opt>/,'')
81
- # file = File.new(zipDirPath+'xl/_rels/workbook.xml.rels', 'w+')
82
- # file.write(contents)
83
- # file.close
84
- #
85
- # contents = XmlSimple.xml_in(zipDirPath+'xl/styles.xml')
86
- # contents = XmlSimple.xml_out(contents).gsub(/<\/?opt>/,'')
87
- # file = File.new(zipDirPath+'xl/styles.xml', 'w+')
88
- # file.write(contents)
89
- # file.close
90
- #
91
- # contents = XmlSimple.xml_in(zipDirPath+'xl/workbook.xml')
92
- # contents = XmlSimple.xml_out(contents).gsub(/<\/?opt>/,'')
93
- # file = File.new(zipDirPath+'xl/workbook.xml', 'w+')
94
- # file.write(contents)
95
- # file.close
96
- #
97
- # #commented out because i copy this anyway
98
- # # contents = XmlSimple.xml_in(zipDirPath+'xl/theme/theme1.xml')
99
- # # contents = XmlSimple.xml_out(contents).gsub(/<\/?opt>/,'')
100
- # # file = File.new(zipDirPath+'[Content_Types].xml', 'w+')
101
- # # file.write(contents)
102
- # # file.close
103
- #
104
- # contents = XmlSimple.xml_in(zipDirPath+'xl/worksheets/sheet1.xml')
105
- # contents = XmlSimple.xml_out(contents).gsub(/<\/?opt>/,'')
106
- # file = File.new(zipDirPath+'xl/worksheets/sheet1.xml', 'w+')
107
- # file.write(contents)
108
- # file.close
109
-
110
- #TODO manually reorder the xml tags to correlate, then compress using this compression method,
111
- #(not archive utility), then see if that xlsx file opens
112
-
113
- z.compress('/Users/vbhagwat/Desktop/test2/Workbook1/')
114
-
115
-
116
- # compress(dirPath)
117
-
118
- end
data/lib/tests/test3.rb DELETED
@@ -1,76 +0,0 @@
1
- require 'rubygems'
2
- require 'FileUtils'
3
- require 'writer'
4
-
5
-
6
- module RubyXL
7
-
8
- def convertToIndex(cellString)
9
- index = Array.new(2)
10
- index[0]=-1
11
- index[1]=-1
12
- if(cellString =~ /^([A-Z]+)(\d+)/)
13
- one = $1.to_s()
14
- row = Integer($2) - 1 #-1 for 0 indexing
15
- col = 0
16
- i = 0
17
- one = one.reverse #because of 26^i calculation
18
- one.each_byte do |c|
19
- intVal = c - 64 #converts A to 1 (0, actually)
20
- col += intVal * 26**(i)
21
- i=i+1
22
- end
23
- col -= 1 #zer0 index
24
- index[0] = row
25
- index[1] = col
26
- end
27
- index
28
- end
29
-
30
-
31
- #TODO FIX THIS
32
- def convertToCell(row, col)
33
- puts "input = (#{row}, #{col})"
34
- #convert col to letter, convert row to row-1, join
35
- rowString = (row + 1).to_s #+1 for 0 indexing
36
- colString = ''
37
- unless col == 0
38
- colLength = 1+Integer(Math.log(col) / Math.log(26)) #opposite of 26**
39
- else
40
- colLength = 1
41
- end
42
-
43
- puts "colLength = #{colLength}"
44
- 1.upto(colLength) do |i|
45
- puts "i = #{i}"
46
- puts "col = #{col}"
47
- puts "26**(colLength-i) = #{26**(colLength-i)}"
48
-
49
- if i == colLength
50
- col+=1
51
- end
52
-
53
- if col >= 26**(colLength-i)
54
- intVal = col / 26**(colLength-i) #+1 for 0 indexing
55
- intVal += 64 #converts 1 to A, etc.
56
- puts "intVal = #{intVal}"
57
- puts "col = #{col}, #{intVal.chr}"
58
-
59
- # colString = intVal.chr + colString
60
- colString += intVal.chr
61
-
62
- puts "colString = #{colString}"
63
- col -= (intVal-64)*26**(colLength-i)
64
- end
65
- end
66
- p colString
67
- p rowString
68
-
69
- colString+rowString
70
- end
71
- row = 0
72
- col = 16168
73
-
74
- puts "(#{row},#{col})=>#{convertToCell(row,col)}"
75
-
76
- end
data/lib/tests/test4.rb DELETED
@@ -1,92 +0,0 @@
1
- require 'rubygems'
2
- require 'zip/zip'
3
- # require 'File'
4
- require 'FileUtils'
5
-
6
- module RubyXL
7
- # class Test4
8
- def write_content_types()
9
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
10
- <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/><Default Extension="jpeg" ContentType="image/jpeg"/><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/></Types>'
11
- end
12
-
13
- def write_root_rels()
14
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
15
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" Target="docProps/thumbnail.jpeg"/></Relationships>'
16
- end
17
-
18
- def write_core_properties()
19
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
20
- <cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:creator>Vivek Bhagwat</dc:creator><cp:lastModifiedBy>Vivek Bhagwat</cp:lastModifiedBy><dcterms:created xsi:type="dcterms:W3CDTF">2011-05-25T19:40:48Z</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">2011-05-25T19:40:51Z</dcterms:modified></cp:coreProperties>'
21
- end
22
-
23
- def write_app_properties()
24
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
25
- <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Macintosh Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><HeadingPairs><vt:vector size="2" baseType="variant"><vt:variant><vt:lpstr>Worksheets</vt:lpstr></vt:variant><vt:variant><vt:i4>1</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector size="1" baseType="lpstr"><vt:lpstr>Sheet1</vt:lpstr></vt:vector></TitlesOfParts><Company>Gilt Groupe</Company><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>12.0000</AppVersion></Properties>'
26
- end
27
-
28
- def write_workbook_rels()
29
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
30
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>'
31
- end
32
-
33
- def write_workbook()
34
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
35
- <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><fileVersion appName="xl" lastEdited="4" lowestEdited="4" rupBuild="4505"/><workbookPr date1904="1" showInkAnnotation="0" autoCompressPictures="0"/><bookViews><workbookView xWindow="-20" yWindow="-20" windowWidth="34400" windowHeight="22000" tabRatio="500"/></bookViews><sheets><sheet name="Sheet1" sheetId="1" r:id="rId1"/></sheets><calcPr calcId="130407" concurrentCalc="0"/><extLst><ext xmlns:mx="http://schemas.microsoft.com/office/mac/excel/2008/main" uri="http://schemas.microsoft.com/office/mac/excel/2008/main"><mx:ArchID Flags="2"/></ext></extLst></workbook>'
36
- end
37
-
38
- #only writes sheet1.xml
39
- def write_worksheet()
40
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
41
- <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" mc:Ignorable="mv" mc:PreserveAttributes="mv:*"><dimension ref="A1"/><sheetViews><sheetView tabSelected="1" view="pageLayout" workbookViewId="0"/></sheetViews><sheetFormatPr baseColWidth="10" defaultRowHeight="13"/><sheetData/><phoneticPr fontId="1" type="noConversion"/><pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5"/><pageSetup orientation="portrait" horizontalDpi="4294967292" verticalDpi="4294967292"/><extLst><ext xmlns:mx="http://schemas.microsoft.com/office/mac/excel/2008/main" uri="http://schemas.microsoft.com/office/mac/excel/2008/main"><mx:PLV Mode="1" OnePage="0" WScale="0"/></ext></extLst></worksheet>'
42
- end
43
-
44
- def write_styles()
45
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
46
- <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="2"><font><sz val="10"/><name val="Verdana"/></font><font><sz val="8"/><name val="Verdana"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles><dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium9"/></styleSheet>'
47
- end
48
-
49
- def write_theme()
50
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
51
- <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="100000"/><a:shade val="100000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="50000"/><a:shade val="100000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults><a:spDef><a:spPr/><a:bodyPr/><a:lstStyle/><a:style><a:lnRef idx="1"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="3"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="2"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="lt1"/></a:fontRef></a:style></a:spDef><a:lnDef><a:spPr/><a:bodyPr/><a:lstStyle/><a:style><a:lnRef idx="2"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="0"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="1"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="tx1"/></a:fontRef></a:style></a:lnDef></a:objectDefaults><a:extraClrSchemeLst/></a:theme>'
52
- end
53
-
54
- filepath = '/Users/vbhagwat/Desktop/blankWorkbook.xlsx'
55
- dirpath = ''
56
- if(filepath =~ /((.|\s)*)\.xlsx$/)
57
- dirpath = $1.to_s()
58
- end
59
- filename = ''
60
- if(filepath =~ /\/((.|\s)*)\/((.|\s)*)\.xlsx$/)
61
- filename = $3.to_s()
62
- end
63
- # p filepath
64
- # p dirpath
65
- # p filename
66
-
67
- zippath = dirpath + '/' + filename + '.zip'
68
- File.unlink(zippath) if File.exists?(zippath)
69
- Zip::ZipFile.open(zippath, Zip::ZipFile::CREATE) do |zipfile|
70
- zipfile.get_output_stream('[Content_Types].xml') {|f| f.puts(write_content_types())}
71
-
72
- zipfile.get_output_stream('_rels/.rels') {|f| f.puts(write_root_rels())}
73
-
74
- zipfile.get_output_stream('docProps/app.xml') {|f| f.puts(write_app_properties())}
75
-
76
- zipfile.get_output_stream('docProps/core.xml') {|f| f.puts(write_core_properties())}
77
-
78
- zipfile.get_output_stream('xl/theme/theme1.xml') {|f| f.puts(write_theme())}
79
-
80
- zipfile.get_output_stream('xl/_rels/workbook.xml.rels') {|f| f.puts(write_workbook_rels())}
81
-
82
- zipfile.get_output_stream('xl/workbook.xml') {|f| f.puts(write_workbook())}
83
-
84
- zipfile.get_output_stream('xl/styles.xml') {|f| f.puts(write_styles())}
85
-
86
- zipfile.get_output_stream('xl/worksheets/sheet1.xml') {|f| f.puts(write_worksheet())}
87
-
88
- zipfile.add('docProps/thumbnail.jpeg','/Users/vbhagwat/Desktop/test2/Workbook1/docProps/thumbnail.jpeg')
89
- # zipfile.get_output_stream('docProps/thumbnail.jpeg') {|f| }
90
- end
91
- # end
92
- end
data/lib/tests/test5.rb DELETED
@@ -1,90 +0,0 @@
1
- require '../rubyXL'
2
- require 'rubygems'
3
- require 'nokogiri'
4
- # require File.expand_path(File.join(File.dirname(__FILE__),'Hash'))
5
- # require File.expand_path(File.join(File.dirname(__FILE__),'cell'))
6
- # require File.expand_path(File.join(File.dirname(__FILE__),'workbook'))
7
- # require File.expand_path(File.join(File.dirname(__FILE__),'parser'))
8
-
9
- # module RubyXL
10
- file_path = '/Users/vbhagwat/Documents/excelTestFiles/styledWorkbook2/styledWorkbook2.xlsx'
11
- wb = RubyXL::Parser.parse(file_path)
12
- puts "parsed #{file_path}"
13
- p wb.cell_xfs
14
- cell = wb.worksheets[0].sheet_data[0][0]
15
- cell2 = wb.worksheets[0].sheet_data[1][1]
16
- cell3 = wb.worksheets[0].sheet_data[0][2]
17
-
18
- cell4 = wb.worksheets[0].add_cell(4,4,'test')
19
- cell5 = wb.worksheets[0].add_cell(4,4,'test2',nil,false)
20
-
21
- # cells = Array.new()
22
- #
23
- # cells << Cell.new(0,3,'black', nil,'str') #8
24
- # cells << Cell.new(0,4,'white',nil,'str')
25
- # cells << Cell.new(0,5,'red',nil,'str')
26
- # cells << Cell.new(0,6,'brightgreen',nil,'str')
27
- # cells << Cell.new(0,7,'blue',nil,'str')
28
- # cells << Cell.new(0,8,'yellow',nil,'str')
29
- # cells << Cell.new(0,9,'magenta',nil,'str')
30
- # cells << Cell.new(0,10,'cyan',nil,'str')
31
- # cells << Cell.new(0,11,'darkred',nil,'str')
32
- # cells << Cell.new(0,12,'green',nil,'str')
33
- # cells << Cell.new(0,13,'darkblue',nil,'str')
34
- # cells << Cell.new(0,14,'darkyellow',nil,'str')
35
- # cells << Cell.new(0,15,'purple',nil,'str')
36
- # cells << Cell.new(0,16,'teal',nil,'str')
37
- # cells << Cell.new(0,17,'gray25',nil,'str')
38
- # cells << Cell.new(0,18,'gray50',nil,'str') #23
39
- # 19.upto(58) do |ind|
40
- # cells << Cell.new(0,ind,(ind+5).to_s,nil,'str')
41
- # end
42
- #
43
- # cells.each_with_index do |c,i|
44
- # wb.worksheets[0].sheet_data[0] << c
45
- # c.change_fill((i+8).to_s)
46
- # end
47
- def print_stuff(wb)
48
- puts 'begin print_stuff'
49
- puts ''
50
- puts ''
51
- puts ''
52
- p wb.cell_xfs[:xf][0]
53
- puts ''
54
- puts ''
55
- puts ''
56
- puts 'end print_stuff'
57
- end
58
-
59
- print_stuff(wb)
60
- cell.change_font_name('Verdana')
61
- print_stuff(wb)
62
- cell2.change_font_size(30)
63
- print_stuff(wb)
64
- cell.change_fill('ff0000')
65
- print_stuff(wb)
66
- wb.worksheets[0].change_row_font_name(1,'Courier')
67
- print_stuff(wb)
68
- wb.worksheets[0].change_row_fill(1,'00ff00')
69
- print_stuff(wb)
70
- wb.worksheets[0].change_column_font_size(0,20)
71
- print_stuff(wb)
72
- cell.change_font_bold(false)
73
- print_stuff(wb)
74
- cell2.change_font_underline(true)
75
- print_stuff(wb)
76
- cell3.change_fill('000000')
77
- print_stuff(wb)
78
- cell3.change_font_name('Verddddana')
79
- print_stuff(wb)
80
- # cell3.change_fill('52')
81
-
82
- wb.write('/Users/vbhagwat/Desktop/test2/Output/cell.xlsx')
83
-
84
- p wb.style_corrector
85
-
86
- print_stuff(wb)
87
- puts 'completed writing /Users/vbhagwat/Desktop/test2/Output/cell.xlsx'
88
- #TODO
89
-
90
- # end
data/lib/tests/test6.rb DELETED
@@ -1,50 +0,0 @@
1
- require '../rubyXL'
2
- require 'rubygems'
3
- # require File.expand_path(File.join(File.dirname(__FILE__),'workbook'))
4
- # require File.expand_path(File.join(File.dirname(__FILE__),'parser'))
5
- # require File.expand_path(File.join(File.dirname(__FILE__),'color'))
6
- # require File.expand_path(File.join(File.dirname(__FILE__),'cell'))
7
-
8
- module RubyXL
9
- wb = Workbook.new([],nil)
10
- wb.worksheets = [Worksheet.new(wb,'Sheet1')]
11
- cell = wb.worksheets[0].add_cell(0,0,'1.00.0')
12
- # cell.change_font_italics(false)
13
- # p cell.is_italicized(wb)
14
- # cell.change_font_bold(false)
15
- # p cell.is_bolded(wb)
16
- # cell.change_font_underline(false)
17
- # p cell.is_underlined(wb)
18
- # p cell.font_name(wb)
19
- # p cell.font_size(wb)
20
- # p cell.font_color(wb)
21
- # p cell.fill_color(wb)
22
-
23
- wb.worksheets[0].add_cell(2,5,'$1,000.00')
24
- wb.worksheets[0].add_cell(3,3,'6/14/11')
25
- wb.worksheets[0].add_cell(4,0,1)
26
- wb.worksheets[0].add_cell(4,1,2)
27
- wb.worksheets[0].add_cell(4,2,3)
28
- wb.worksheets[0].add_cell(4,3,4)
29
- wb.worksheets[0].add_cell(4,4,0,'AVERAGE(A5:D5)')
30
-
31
- cell.change_font_color('ff0000')
32
-
33
- wb.write('/Users/vbhagwat/Desktop/test2/Output/nums.xlsx')
34
-
35
-
36
- wb2 = Parser.parse('/Users/vbhagwat/Desktop/5-1_5-20.xlsx')
37
- # wb2.worksheets[0].merge_cells(0,1,0,2)
38
- # wb2.worksheets[0].merge_cells(0,0,0,1)
39
- #.change_font_size(30)
40
- wb2.write('/Users/vbhagwat/Desktop/test2/Output/nums2.xlsx')
41
-
42
- wb3 = Parser.parse('/Users/vbhagwat/Documents/excelTestFiles/paneWorkbook2/paneWorkbook2.xlsx')
43
-
44
-
45
-
46
- # p Color.find(8)
47
- # c = Color::ColorProperties
48
- # p c.has_value?({:hex=>'#000000', :name=>"black"})
49
- # p Color.find('black')
50
- end
data/lib/tests/test7.rb DELETED
@@ -1,48 +0,0 @@
1
- require '../rubyXL'
2
- require 'rubygems'
3
- require 'rubyXL'
4
- # require File.expand_path(File.join(File.dirname(__FILE__),'workbook'))
5
-
6
- module RubyXL
7
- wb = Workbook.new([],nil)
8
- wb.worksheets = [Worksheet.new(wb,'Sheet1')]
9
-
10
- cell = wb.worksheets[0].add_cell(0,0,'A1')
11
- cell2 = wb.worksheets[0].add_cell(0,1,'B1')
12
- cell3 = wb.worksheets[0].add_cell(0,5,'F1')
13
-
14
- wb.worksheets[0].sheet_data[0].each do |c|
15
- unless c.nil?
16
- c.change_font_bold(true)
17
- c.change_font_underline(true)
18
- end
19
- end
20
-
21
- cell.change_horizontal_alignment('center')
22
- wb.worksheets[0].change_row_horizontal_alignment(0,'justify')
23
- wb.worksheets[0].change_row_vertical_alignment(0,'center')
24
-
25
- wb.worksheets[0].change_row_fill(0,'FF0000')
26
- cell2.change_fill('0000FF')
27
-
28
- cell4 = wb.worksheets[0].add_cell(0,3,'D1')
29
- puts '
30
-
31
-
32
-
33
- '
34
- p wb.fills
35
- puts '
36
-
37
-
38
-
39
-
40
- '
41
- cell4.change_fill('A43502')
42
-
43
- cell5 = wb.worksheets[0].add_cell(1,0,'A2')
44
- wb.worksheets[0].change_row_fill(1,'00FF00')
45
- cell5.change_fill('FF0000')
46
-
47
- wb.write('/Users/vbhagwat/Desktop/test2/Output/test7.xlsx')
48
- end
data/lib/tests/test8.rb DELETED
@@ -1,12 +0,0 @@
1
- require '../rubyXL'
2
- require 'rubygems'
3
- # require File.expand_path(File.join(File.dirname(__FILE__),'workbook'))
4
- # require File.expand_path(File.join(File.dirname(__FILE__),'parser'))
5
-
6
- module RubyXL
7
-
8
- wb = Parser.parse('/Users/vbhagwat/Desktop/macros.xlsm', false)
9
- wb.write('/Users/vbhagwat/Desktop/test2/Output/macros.xlsm')
10
- puts "completed writing /Users/vbhagwat/Desktop/test2/Output/macros.xlsm"
11
-
12
- end
data/lib/tests/test9.rb DELETED
@@ -1,60 +0,0 @@
1
- require 'rubygems'
2
- require 'nokogiri'
3
- require File.expand_path(File.join(File.dirname(__FILE__),'Hash'))
4
-
5
- module RubyXL
6
- testWb = Nokogiri::XML.parse(File.read('/Users/vbhagwat/Desktop/testWorkbook.xml'))
7
- testStyles = Nokogiri::XML.parse(File.read('/Users/vbhagwat/Desktop/testStyles.xml'))
8
-
9
- puts "testWb.css('workbook definedNames')[0]"
10
- p testWb.css('workbook definedNames')[0]
11
- puts '/css'
12
-
13
-
14
-
15
-
16
- Hash.xml_node_to_hash(test_wb.css('workbook definedNames')[0])
17
-
18
- puts '
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
- '
39
- h= Hash.xml_node_to_hash(test_styles.css('styleSheet cellXfs')[0])
40
-
41
- puts '
42
-
43
-
44
-
45
-
46
-
47
- '
48
- p h
49
- #
50
- # :cellXfs=>{
51
- # :xf=>[{
52
- # :attributes=>{
53
- # :xfId=>0, :fontId=>0, :numFmtId=>0, :borderId=>0, :fillId=>0}},
54
- # {:attributes=>{
55
- # :applyFill=>0, :applyFont=>0, :applyAlignment=>1, :xfId=>0, :fontId=>0,
56
- # :numFmtId=>0, :applyNumberFormat=>0, :borderId=>0, :applyBorder=>0, :fillId=>0},
57
- # :alignment=>{:attributes=>{:horizontal=>"center"}}}],
58
- #
59
- # :attributes=>{:count=>2}}
60
- end