xlsxwriter 0.1.1 → 0.1.2.pre

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4803495a8461935936f93daa7b11167935d977415e3a64279ace94a15a9ee55
4
- data.tar.gz: 7c9b3293a7166a11739bb1ec794a852248914fcac8d5f759058b035c6a0f4e84
3
+ metadata.gz: 2fb20c025afb481308dc6787fa972d8e5675c20b6de467ade855dc051b1b48f2
4
+ data.tar.gz: 04535f83606938834b2eca512d68a38c4b3e056c4ee660a06e86f8a20ea1454e
5
5
  SHA512:
6
- metadata.gz: 6dd4d9ab1eb21b5b2eb2f92d8f5b6d7753af94ad85dfeadbff8dad24f0c7c2ca7a3791762bed349560f3165226c47f573020f5318173232a9d16644aa1346a72
7
- data.tar.gz: 18730b942a2015143aceb297014755da8465a6db55b51033e97a73f2d57f335efd2c4fafceb3b665ea0797b1df6bdcf11eb373ef6e330025943e7414281bfb19
6
+ metadata.gz: a3e97984e91290594bf91c438de8ad68f271de79b0dd7bbdef36539f1fe47db589269a956e00b69e75a41ad7fbd627dd143e37abe7e8d6c1cdc1341fab42dbd2
7
+ data.tar.gz: 1a7d898c096afef2e230d04db7e0180c8dca48bfc72c7cbca6819a300fc8259ad70d6cf55a85368e9df37d717522760725c7d4e878732973ccaf410ce8ba3490
@@ -352,15 +352,18 @@ value_to_lxw_datetime(VALUE val) {
352
352
  if (rb_respond_to(val, i_to_time)) {
353
353
  val = rb_funcall(val, i_to_time, 0);
354
354
  }
355
+ VALUE time_a = rb_funcall(val, rb_intern("to_a"), 0);
356
+ static const VALUE idxs[6] = { INT2FIX(0), INT2FIX(1), INT2FIX(2), INT2FIX(3), INT2FIX(4), INT2FIX(5) };
355
357
  lxw_datetime res = {
356
- .year = NUM2INT(rb_funcall(val, rb_intern("year"), 0)),
357
- .month = NUM2INT(rb_funcall(val, rb_intern("month"), 0)),
358
- .day = NUM2INT(rb_funcall(val, rb_intern("day"), 0)),
359
- .hour = NUM2INT(rb_funcall(val, rb_intern("hour"), 0)),
360
- .min = NUM2INT(rb_funcall(val, rb_intern("min"), 0)),
361
- .sec = NUM2DBL(rb_funcall(val, rb_intern("sec"), 0)) +
362
- NUM2DBL(rb_funcall(val, rb_intern("subsec"), 0))
358
+ .year = NUM2INT(rb_ary_aref(1, idxs+5, time_a)),
359
+ .month = NUM2INT(rb_ary_aref(1, idxs+4, time_a)),
360
+ .day = NUM2INT(rb_ary_aref(1, idxs+3, time_a)),
361
+ .hour = NUM2INT(rb_ary_aref(1, idxs+2, time_a)),
362
+ .min = NUM2INT(rb_ary_aref(1, idxs+1, time_a)),
363
+ .sec = NUM2DBL(rb_ary_aref(1, idxs+0, time_a)) +
364
+ NUM2DBL(rb_funcall(val, rb_intern("subsec"), 0))
363
365
  };
366
+
364
367
  return res;
365
368
  }
366
369
 
@@ -206,7 +206,7 @@ worksheet_write_formula_(int argc, VALUE *argv, VALUE self) {
206
206
  VALUE worksheet_write_array_formula_(int argc, VALUE *argv, VALUE self) {
207
207
  lxw_row_t row_from, row_to;
208
208
  lxw_col_t col_from, col_to;
209
- const char *str;
209
+ const char *str = NULL;
210
210
  VALUE format_key = Qnil;
211
211
 
212
212
  rb_check_arity(argc, 2, 6);
@@ -215,6 +215,8 @@ VALUE worksheet_write_array_formula_(int argc, VALUE *argv, VALUE self) {
215
215
  if (larg < argc) {
216
216
  str = StringValueCStr(argv[larg]);
217
217
  ++larg;
218
+ } else {
219
+ rb_raise(rb_eArgError, "No formula specified");
218
220
  }
219
221
 
220
222
  if (larg < argc) {
@@ -365,8 +367,8 @@ worksheet_write_boolean_(int argc, VALUE *argv, VALUE self) {
365
367
  }
366
368
 
367
369
  /* call-seq:
368
- * ws.write_datetime(cell, format = nil) -> self
369
- * ws.write_datetime(row, col, format = nil) -> self
370
+ * ws.write_blank(cell, format = nil) -> self
371
+ * ws.write_blank(row, col, format = nil) -> self
370
372
  *
371
373
  * Make a +cell+ blank with +format+.
372
374
  */
@@ -2,5 +2,5 @@
2
2
 
3
3
  module XlsxWriter
4
4
  # :nodoc:
5
- VERSION='0.1.1'.freeze
5
+ VERSION='0.1.2.pre'.freeze
6
6
  end
@@ -20,14 +20,18 @@ class XlsxWriter::Worksheet
20
20
  row_idx = @current_row ||= 0
21
21
  @current_row += 1
22
22
 
23
+ style_ary = style if style.is_a?(Array)
24
+ types_ary = types if types.is_a?(Array)
25
+
23
26
  row.each_with_index do |value, idx|
24
- cell_style = style.is_a?(Array) ? style[idx] : style
25
- cell_type = types.is_a?(Array) ? types[idx] : types
27
+ cell_style = style_ary ? style_ary[idx] : style
28
+ cell_type = types_ary ? types_ary[idx] : types
26
29
 
27
30
  case cell_type && cell_type.to_sym
28
31
  when :string
29
- write_string(row_idx, idx, value.to_s, cell_style)
30
- update_col_auto_width(idx, value.to_s, cell_style)
32
+ value = value.to_s
33
+ write_string(row_idx, idx, value, cell_style)
34
+ update_col_auto_width(idx, value, cell_style)
31
35
  when :number
32
36
  write_number(row_idx, idx, value.to_f, cell_style)
33
37
  when :formula
@@ -49,19 +53,19 @@ class XlsxWriter::Worksheet
49
53
  write_number(row_idx, idx, value, cell_style)
50
54
  when TrueClass, FalseClass
51
55
  write_boolean(row_idx, idx, value, cell_style)
56
+ when Time, (defined?(Date) ? Date : Time)
57
+ write_datetime(row_idx, idx, value, cell_style)
52
58
  when '', nil
53
59
  write_blank(row_idx, idx, cell_style) unless skip_empty
54
60
  when /\A=/
55
61
  write_formula(row_idx, idx, value, cell_style)
56
- else
57
- if value.is_a?(Time) ||
58
- (defined?(Date) && value.is_a?(Date)) ||
59
- (defined?(DateTime) && value.is_a?(DateTime))
60
- write_datetime(row_idx, idx, value.to_time, cell_style)
61
- else # assume string
62
- write_string(row_idx, idx, value.to_s, cell_style)
63
- update_col_auto_width(idx, value.to_s, cell_style)
64
- end
62
+ when String
63
+ write_string(row_idx, idx, value, cell_style)
64
+ update_col_auto_width(idx, value, cell_style)
65
+ else # assume string
66
+ value = value.to_s
67
+ write_string(row_idx, idx, value, cell_style)
68
+ update_col_auto_width(idx, value, cell_style)
65
69
  end
66
70
  else
67
71
  raise ArgumentError, "Unknown cell type #{cell_type}."
@@ -87,6 +91,6 @@ class XlsxWriter::Worksheet
87
91
  font_scale = (@workbook.font_sizes[format] || 11) / 10.0
88
92
  width = (val.count(THIN_CHARS) + 3) * font_scale
89
93
  width = 255 if width > 255 # Max xlsx column width is 255 characters
90
- @col_auto_widths[idx] = [@col_auto_widths[idx], width].compact.max
94
+ @col_auto_widths[idx] = [@col_auto_widths[idx] || 0, width].max
91
95
  end
92
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsxwriter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick H
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-07 00:00:00.000000000 Z
11
+ date: 2019-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -195,9 +195,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - ">="
198
+ - - ">"
199
199
  - !ruby/object:Gem::Version
200
- version: '0'
200
+ version: 1.3.1
201
201
  requirements: []
202
202
  rubygems_version: 3.0.3
203
203
  signing_key: