rubyXL 1.2.7 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.7
1
+ 1.2.8
data/lib/rubyXL/cell.rb CHANGED
@@ -17,7 +17,10 @@ module RubyXL
17
17
  @formula_attributes = fmla_attr
18
18
  end
19
19
 
20
- def value
20
+ def value(args = {})
21
+ raw_values = args.delete(:raw) || false
22
+ return @value if raw_values
23
+
21
24
  if is_date?
22
25
  return @workbook.num_to_date(@value)
23
26
  else
data/lib/rubyXL/parser.rb CHANGED
@@ -98,6 +98,12 @@ module RubyXL
98
98
 
99
99
  #fills hashes for various styles
100
100
  def Parser.fill_styles(wb,style_hash)
101
+ ###NUM FORMATS###
102
+ if style_hash[:numFmts].nil?
103
+ style_hash[:numFmts] = {:attributes => {:count => 0}, :numFmt => []}
104
+ elsif style_hash[:numFmts][:attributes][:count]==1
105
+ style_hash[:numFmts][:numFmt] = [style_hash[:numFmts][:numFmt]]
106
+ end
101
107
  wb.num_fmts = style_hash[:numFmts]
102
108
 
103
109
  ###FONTS###
@@ -336,6 +342,7 @@ module RubyXL
336
342
  if File.directory?(File.join(dir_path,'xl','externalLinks'))
337
343
  files['externalLinks'] = {}
338
344
  ext_links_path = File.join(dir_path,'xl','externalLinks')
345
+ FileUtils.mkdir_p(ext_links_path)
339
346
  files['externalLinks']['rels'] = []
340
347
  dir = Dir.new(ext_links_path).entries.reject {|f| [".", "..", ".DS_Store", "_rels"].include? f}
341
348
 
@@ -354,7 +361,7 @@ module RubyXL
354
361
  if File.directory?(File.join(dir_path,'xl','drawings'))
355
362
  files['drawings'] = {}
356
363
  drawings_path = File.join(dir_path,'xl','drawings','_rels')
357
-
364
+ FileUtils.mkdir_p(drawings_path)
358
365
  dir = Dir.new(drawings_path).entries.reject {|f| [".", "..", ".DS_Store"].include? f}
359
366
  dir.each_with_index do |draw,i|
360
367
  files['drawings'][i+1] = File.read(File.join(drawings_path,draw))
@@ -364,7 +371,7 @@ module RubyXL
364
371
  if File.directory?(File.join(dir_path,'xl','printerSettings'))
365
372
  files['printerSettings'] = {}
366
373
  printer_path = File.join(dir_path,'xl','printerSettings')
367
-
374
+ FileUtils.mkdir_p(printer_path)
368
375
  dir = Dir.new(printer_path).entries.reject {|f| [".","..",".DS_Store"].include? f}
369
376
 
370
377
  dir.each_with_index do |print, i|
@@ -375,7 +382,7 @@ module RubyXL
375
382
  if File.directory?(File.join(dir_path,"xl",'worksheets','_rels'))
376
383
  files['worksheetRels'] = {}
377
384
  worksheet_rels_path = File.join(dir_path,'xl','worksheets','_rels')
378
-
385
+ FileUtils.mkdir_p(worksheet_rels_path)
379
386
  dir = Dir.new(worksheet_rels_path).entries.reject {|f| [".","..",".DS_Store"].include? f}
380
387
  dir.each_with_index do |rel, i|
381
388
  files['worksheetRels'][i+1] = File.read(File.join(worksheet_rels_path,rel))
@@ -32,8 +32,9 @@ class Worksheet < PrivateClass
32
32
  end
33
33
 
34
34
  #returns 2d array of just the cell values (without style or formula information)
35
- def extract_data
36
- return @sheet_data.map {|row| row.map {|c| if c.is_a?(Cell) then c.value else nil end}}
35
+ def extract_data(args = {})
36
+ raw_values = args.delete(:raw) || false
37
+ return @sheet_data.map {|row| row.map {|c| if c.is_a?(Cell) then c.value(:raw => raw_values) else nil end}}
37
38
  end
38
39
 
39
40
  def get_table(headers=[],opts={})
data/rubyXL.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubyXL}
8
- s.version = "1.2.7"
8
+ s.version = "1.2.8"
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{2012-04-10}
12
+ s.date = %q{2012-07-11}
13
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 = [
@@ -49,6 +49,13 @@ describe RubyXL::Parser do
49
49
  @workbook2[0].sheet_data.should == @workbook[0].sheet_data
50
50
  @workbook2[0].sheet_name.should == @workbook[0].sheet_name
51
51
  end
52
+
53
+ it 'should construct consistent number formats' do
54
+ @workbook2 = RubyXL::Parser.parse(@file)
55
+
56
+ @workbook2.num_fmts[:numFmt].should be_an(Array)
57
+ @workbook2.num_fmts[:numFmt].length.should == @workbook2.num_fmts[:attributes][:count]
58
+ end
52
59
  end
53
60
 
54
61
  after do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyXL
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 7
9
+ - 8
10
10
  segments_generated: true
11
- version: 1.2.7
11
+ version: 1.2.8
12
12
  platform: ruby
13
13
  authors:
14
14
  - Vivek Bhagwat
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-04-10 00:00:00 -04:00
19
+ date: 2012-07-11 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency