write_xlsx 0.69.0 → 0.70.0

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
  SHA1:
3
- metadata.gz: 0b64b508ff280aa34008fca70ef3554cfd2aae0f
4
- data.tar.gz: e9ca4ef7d80c4bf39be76c842725fd08f71d22fa
3
+ metadata.gz: 3bc15768bd6ed7228ff33b5a332b90c0f996b8e0
4
+ data.tar.gz: 3e3a148d8c17d061b6fb8f11c82a0a09e87645a8
5
5
  SHA512:
6
- metadata.gz: 2b857dd675e58f9f2bc4e064ad133d4237c87d27809852688bd2e2f58ea70fb520b239a1924b92a4856c866fbcdb73ece933808f1aa5380d6a31c3b91e3fd8ff
7
- data.tar.gz: 6ea66fc1fe51560bde230f42a5d6b119b59285a321f86f7c7d9776fcd83b24f4b21afcedd8be954df17a173d113a0dd765b830e704309219a365454be34ad5b2
6
+ metadata.gz: bdaf8c7ef0d30401256fd972b5b27ebc85e6a07bc5e06279ace3a0e5befb65dfc3fe7e9c54e4a53e0c615a16123ff596081a2619bfd99b20872d7aa59d35ba20
7
+ data.tar.gz: 4c76548dbb4d508f6c5801eb772a717a9f1a18d803f650d310428f705b6d16d6343f5c1b31d6265b570eace0d603ceb9119c39a0c09b5590dcfd4d1f6753d36b
data/README.rdoc CHANGED
@@ -75,6 +75,11 @@ the first worksheet in an Excel XML spreadsheet called ruby.xlsx:
75
75
  workbook.close
76
76
 
77
77
  == Recent change
78
+ 2013-07-13 v0.70.0
79
+ Fix for rendering images that are the same size as cell boundaries.
80
+ Fix for inaccurate column width calculation.
81
+ Added Chart line smoothing option.
82
+
78
83
  2013-06-30 v0.69.0
79
84
  Added chart font rotation property. Mainly for use with data axes to make the display more compact.
80
85
  Fix for issue where shapes on one worksheet corrupted charts on a subsequent worksheet.
@@ -575,6 +575,7 @@ def initialize(subtype) # :nodoc:
575
575
  @x_offset = 0
576
576
  @y_offset = 0
577
577
  @table = nil
578
+ @smooth_allowed = 0
578
579
 
579
580
  set_default_properties
580
581
  end
@@ -1118,6 +1119,9 @@ def add_series(params)
1118
1119
  # Set the trendline properties for the series.
1119
1120
  trendline = trendline_properties(params[:trendline])
1120
1121
 
1122
+ # Set the line smooth property for the series.
1123
+ smooth = params[:smooth]
1124
+
1121
1125
  # Set the error bars properties for the series.
1122
1126
  y_error_bars = error_bars_properties(params[:y_error_bars])
1123
1127
  x_error_bars = error_bars_properties(params[:x_error_bars])
@@ -1158,6 +1162,7 @@ def add_series(params)
1158
1162
  :_fill => fill,
1159
1163
  :_marker => marker,
1160
1164
  :_trendline => trendline,
1165
+ :_smooth => smooth,
1161
1166
  :_labels => labels,
1162
1167
  :_invert_if_neg => invert_if_neg,
1163
1168
  :_x2_axis => x2_axis,
@@ -1281,6 +1286,7 @@ def add_series(params)
1281
1286
  # bold
1282
1287
  # italic
1283
1288
  # underline
1289
+ # rotation
1284
1290
  # color
1285
1291
  #
1286
1292
  # The following explains the available font properties:
@@ -1310,6 +1316,13 @@ def add_series(params)
1310
1316
  #
1311
1317
  # chart.set_x_axis( :num_font => { :underline => 1 } )
1312
1318
  #
1319
+ # ===rotation
1320
+ # See the font rotation in the range -90 to 90:
1321
+ #
1322
+ # chart.set_x_axis(:num_font => { :rotation => 45 })
1323
+ #
1324
+ # This is useful for displaying large axis data such as dates in a more compact format.
1325
+ #
1313
1326
  # ===color
1314
1327
  # Set the font color property. Can be a color index, a color name or HTML
1315
1328
  # style RGB colour:
@@ -2574,6 +2587,8 @@ def write_ser(series) # :nodoc:
2574
2587
  write_cat(series)
2575
2588
  # Write the c:val element.
2576
2589
  write_val(series)
2590
+ # Write the c:smooth element.
2591
+ write_c_smooth(series[:_smooth]) if ptrue?(@smooth_allowed)
2577
2592
  end
2578
2593
  end
2579
2594
 
@@ -4151,6 +4166,17 @@ def write_down_bars(format)
4151
4166
  write_bars_base('c:downBars', format)
4152
4167
  end
4153
4168
 
4169
+ #
4170
+ # Write the <c:smooth> element.
4171
+ #
4172
+ def write_c_smooth(smooth)
4173
+ return unless ptrue?(smooth)
4174
+
4175
+ attributes = ['val', 1]
4176
+
4177
+ @writer.empty_tag('c:smooth', attributes)
4178
+ end
4179
+
4154
4180
  def write_bars_base(tag, format)
4155
4181
  if ptrue?(format[:_line][:_defined]) || ptrue?(format[:_fill][:_defined])
4156
4182
  @writer.tag_elements(tag) { write_sp_pr(format) }
@@ -22,6 +22,7 @@ class Line < self
22
22
  def initialize(subtype)
23
23
  super(subtype)
24
24
  @default_marker = {:type => 'none'}
25
+ @smooth_allowed = 1
25
26
  end
26
27
 
27
28
  #
@@ -41,6 +41,7 @@ def initialize(subtype)
41
41
  @cross_between = 'midCat'
42
42
  @horiz_val_axis = 0
43
43
  @val_axis_position = 'b'
44
+ @smooth_allowed = 1
44
45
  end
45
46
 
46
47
  #
@@ -123,7 +124,11 @@ def write_ser(series)
123
124
  # Write the c:yVal element.
124
125
  write_y_val(series)
125
126
  # Write the c:smooth element.
126
- write_c_smooth
127
+ if @subtype =~ /smooth/ && !series[:_smooth]
128
+ write_c_smooth(1)
129
+ else
130
+ write_c_smooth(series[:_smooth])
131
+ end
127
132
  end
128
133
  end
129
134
 
@@ -227,20 +232,6 @@ def write_scatter_style(val)
227
232
  @writer.empty_tag('c:scatterStyle', attributes)
228
233
  end
229
234
 
230
- #
231
- # Write the <c:smooth> element.
232
- #
233
- def write_c_smooth
234
- subtype = @subtype
235
- val = 1
236
-
237
- return unless subtype =~ /smooth/
238
-
239
- attributes = ['val', val]
240
-
241
- @writer.empty_tag('c:smooth', attributes)
242
- end
243
-
244
235
  #
245
236
  # Add default formatting to the series data unless it has already been
246
237
  # specified by the user.
@@ -175,8 +175,7 @@ def calc_position_emus(worksheet)
175
175
  @x_offset,
176
176
  @y_offset,
177
177
  @width * @scale_x,
178
- @height * @scale_y,
179
- @drawing
178
+ @height * @scale_y
180
179
  )
181
180
 
182
181
  # Now that x2/y2 have been calculated with a potentially negative
@@ -1,5 +1,5 @@
1
1
  require 'write_xlsx/workbook'
2
2
 
3
3
  class WriteXLSX < Writexlsx::Workbook
4
- VERSION = "0.69.0"
4
+ VERSION = "0.70.0"
5
5
  end
@@ -5507,7 +5507,7 @@ def prepare_chart(index, chart_id, drawing_id) # :nodoc:
5507
5507
  width = (0.5 + (width * x_scale)).to_i
5508
5508
  height = (0.5 + (height * y_scale)).to_i
5509
5509
 
5510
- dimensions = position_object_emus(col, row, x_offset, y_offset, width, height, false)
5510
+ dimensions = position_object_emus(col, row, x_offset, y_offset, width, height)
5511
5511
 
5512
5512
  # Set the chart name for the embedded object if it has been specified.
5513
5513
  name = chart.name
@@ -5605,7 +5605,7 @@ def get_range_data(row_start, col_start, row_end, col_end) # :nodoc:
5605
5605
  # y2 # Distance to bottom of object.
5606
5606
  # width # Width of object frame.
5607
5607
  # height # Height of object frame.
5608
- def position_object_pixels(col_start, row_start, x1, y1, width, height, is_drawing = false) #:nodoc:
5608
+ def position_object_pixels(col_start, row_start, x1, y1, width, height) #:nodoc:
5609
5609
  # Calculate the absolute x offset of the top-left vertex.
5610
5610
  if @col_size_changed
5611
5611
  x_abs = (1 .. col_start).inject(0) {|sum, col| sum += size_col(col)}
@@ -5644,13 +5644,6 @@ def position_object_pixels(col_start, row_start, x1, y1, width, height, is_drawi
5644
5644
  # Subtract the underlying cell heights to find the end cell of the object.
5645
5645
  height, row_end = adjust_row_offset(height, row_end)
5646
5646
 
5647
- # The following is only required for positioning drawing/chart objects
5648
- # and not comments. It is probably the result of a bug.
5649
- if ptrue?(is_drawing)
5650
- col_end -= 1 if width == 0
5651
- row_end -= 1 if height == 0
5652
- end
5653
-
5654
5647
  # The end vertices are whatever is left from the width and height.
5655
5648
  x2 = width
5656
5649
  y2 = height
@@ -6045,9 +6038,9 @@ def adjust_row_offset(y, row)
6045
6038
  # The vertices are expressed as English Metric Units (EMUs). There are 12,700
6046
6039
  # EMUs per point. Therefore, 12,700 * 3 /4 = 9,525 EMUs per pixel.
6047
6040
  #
6048
- def position_object_emus(col_start, row_start, x1, y1, width, height, is_drawing = true) #:nodoc:
6041
+ def position_object_emus(col_start, row_start, x1, y1, width, height) #:nodoc:
6049
6042
  col_start, row_start, x1, y1, col_end, row_end, x2, y2, x_abs, y_abs =
6050
- position_object_pixels(col_start, row_start, x1, y1, width, height, is_drawing)
6043
+ position_object_pixels(col_start, row_start, x1, y1, width, height)
6051
6044
 
6052
6045
  # Convert the pixel values to EMUs. See above.
6053
6046
  x1 = (0.5 + 9_525 * x1).to_i
@@ -6074,7 +6067,7 @@ def size_col(col) #:nodoc:
6074
6067
  if width == 0
6075
6068
  pixels = 0
6076
6069
  elsif width < 1
6077
- pixels = (width * 12 + 0.5).to_i
6070
+ pixels = (width * (MAX_DIGIT_WIDTH + PADDING) + 0.5).to_i
6078
6071
  else
6079
6072
  pixels = (width * MAX_DIGIT_WIDTH + 0.5).to_i + PADDING
6080
6073
  end
@@ -6542,10 +6535,15 @@ def col_info_attributes(args)
6542
6535
  end
6543
6536
 
6544
6537
  # Convert column width from user units to character width.
6545
- if width && width > 0
6546
- width = ((width * MAX_DIGIT_WIDTH + PADDING) / MAX_DIGIT_WIDTH.to_f * 256).to_i/256.0
6547
- width = width.to_i if width.to_s =~ /\.0+$/
6538
+ if width && width < 1
6539
+ width =
6540
+ ((width * (MAX_DIGIT_WIDTH + PADDING) + 0.5).to_i / MAX_DIGIT_WIDTH.to_f * 256).to_i / 256.0
6541
+ else
6542
+ width =
6543
+ (((width * MAX_DIGIT_WIDTH + 0.5).to_i + PADDING).to_i/ MAX_DIGIT_WIDTH.to_f * 256).to_i / 256.0
6548
6544
  end
6545
+ width = width.to_i if width - width.to_i == 0
6546
+
6549
6547
  attributes = [
6550
6548
  'min', min + 1,
6551
6549
  'max', max + 1,
@@ -20,6 +20,7 @@ def test_add_series_only_values
20
20
  :_fill => { :_defined => 0 },
21
21
  :_marker => nil,
22
22
  :_trendline => nil,
23
+ :_smooth => nil,
23
24
  :_labels => nil,
24
25
  :_invert_if_neg => nil,
25
26
  :_x2_axis => nil,
@@ -51,6 +52,7 @@ def test_add_series_with_categories_and_values
51
52
  :_fill => { :_defined => 0 },
52
53
  :_marker => nil,
53
54
  :_trendline => nil,
55
+ :_smooth => nil,
54
56
  :_labels => nil,
55
57
  :_invert_if_neg => nil,
56
58
  :_x2_axis => nil,
@@ -87,6 +89,7 @@ def test_add_series_only_values_checked_by_array
87
89
  :_fill => { :_defined => 0 },
88
90
  :_marker => nil,
89
91
  :_trendline => nil,
92
+ :_smooth => nil,
90
93
  :_labels => nil,
91
94
  :_invert_if_neg => nil,
92
95
  :_x2_axis => nil,
@@ -118,6 +121,7 @@ def test_add_series_both_checked_by_array
118
121
  :_fill => { :_defined => 0 },
119
122
  :_marker => nil,
120
123
  :_trendline => nil,
124
+ :_smooth => nil,
121
125
  :_labels => nil,
122
126
  :_invert_if_neg => nil,
123
127
  :_x2_axis => nil,
@@ -152,6 +156,7 @@ def test_add_series_secondary_axis
152
156
  :_fill => { :_defined => 0 },
153
157
  :_marker => nil,
154
158
  :_trendline => nil,
159
+ :_smooth => nil,
155
160
  :_labels => nil,
156
161
  :_invert_if_neg => nil,
157
162
  :_x2_axis => 1,
data/test/helper.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'rubygems'
3
+ require 'simplecov' if RUBY_VERSION >= "1.9"
3
4
  require 'bundler'
5
+
6
+ SimpleCov.start if RUBY_VERSION >= "1.9"
7
+
4
8
  begin
5
9
  Bundler.setup(:default, :development)
6
10
  rescue Bundler::BundlerError => e
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartLine03 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_chart_line03
14
+ @xlsx = 'chart_line03.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'line', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [47673728, 47675264])
21
+
22
+ data = [
23
+ [ 5, 2, 3, 4, 3 ],
24
+ [ 10, 4, 6, 8, 6 ],
25
+ [ 15, 6, 9, 12, 9 ]
26
+ ]
27
+
28
+ worksheet.write('A1', data)
29
+
30
+ chart.add_series(:values => '=Sheet1!$A$1:$A$5', :smooth => 1)
31
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
32
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5')
33
+
34
+ worksheet.insert_chart('E9', chart)
35
+
36
+ workbook.close
37
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartLine04 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_chart_line04
14
+ @xlsx = 'chart_line04.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'line', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [47670016, 47671552])
21
+
22
+ data = [
23
+ [ 5, 2, 3, 4, 3 ],
24
+ [ 10, 4, 6, 8, 6 ],
25
+ [ 15, 6, 9, 12, 9 ]
26
+ ]
27
+
28
+ worksheet.write('A1', data)
29
+
30
+ chart.add_series(:values => '=Sheet1!$A$1:$A$5', :smooth => 1)
31
+ chart.add_series(:values => '=Sheet1!$B$1:$B$5')
32
+ chart.add_series(:values => '=Sheet1!$C$1:$C$5', :smooth => 1)
33
+
34
+ worksheet.insert_chart('E9', chart)
35
+
36
+ workbook.close
37
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
38
+ end
39
+ end
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartScatter09 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_chart_scatter09
14
+ @xlsx = 'chart_scatter09.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(
18
+ :type => 'scatter',
19
+ :embedded => 1,
20
+ :subtype => 'smooth_with_markers'
21
+ )
22
+
23
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
24
+ chart.instance_variable_set(:@axis_ids, [45953024, 45954944])
25
+
26
+ data = [
27
+ [1, 2, 3, 4, 5],
28
+ [2, 4, 6, 8, 10],
29
+ [3, 6, 9, 12, 15]
30
+ ]
31
+
32
+ worksheet.write('A1', data)
33
+
34
+ chart.add_series(
35
+ :categories => '=Sheet1!$A$1:$A$5',
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :smooth => 0
38
+ )
39
+
40
+ chart.add_series(
41
+ :categories => '=Sheet1!$A$1:$A$5',
42
+ :values => '=Sheet1!$C$1:$C$5'
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+
49
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
50
+ # @xlsx,
51
+ # nil,
52
+ # {
53
+ # 'xl/charts/chart1.xml' => ['<c:pageMargins'],
54
+ # 'xl/workbook.xml' => [ '<fileVersion', '<calcPr' ]
55
+ # }
56
+ # )
57
+
58
+ end
59
+ end
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartScatter10 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_chart_scatter10
14
+ @xlsx = 'chart_scatter10.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(
18
+ :type => 'scatter',
19
+ :embedded => 1,
20
+ :subtype => 'smooth'
21
+ )
22
+
23
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
24
+ chart.instance_variable_set(:@axis_ids, [84754816, 84756352])
25
+
26
+ data = [
27
+ [1, 2, 3, 4, 5],
28
+ [2, 4, 6, 8, 10],
29
+ [3, 6, 9, 12, 15]
30
+ ]
31
+
32
+ worksheet.write('A1', data)
33
+
34
+ chart.add_series(
35
+ :categories => '=Sheet1!$A$1:$A$5',
36
+ :values => '=Sheet1!$B$1:$B$5'
37
+ )
38
+
39
+ chart.add_series(
40
+ :categories => '=Sheet1!$A$1:$A$5',
41
+ :values => '=Sheet1!$C$1:$C$5',
42
+ :smooth => 0
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+
49
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
50
+ # @xlsx,
51
+ # nil,
52
+ # {
53
+ # 'xl/charts/chart1.xml' => ['<c:pageMargins'],
54
+ # 'xl/workbook.xml' => [ '<fileVersion', '<calcPr' ]
55
+ # }
56
+ # )
57
+
58
+ end
59
+ end
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartScatter11 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_chart_scatter11
14
+ @xlsx = 'chart_scatter11.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(
18
+ :type => 'scatter',
19
+ :embedded => 1,
20
+ :subtype => 'straight_with_markers'
21
+ )
22
+
23
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
24
+ chart.instance_variable_set(:@axis_ids, [47439232, 47670400])
25
+
26
+ data = [
27
+ [1, 2, 3, 4, 5],
28
+ [2, 4, 6, 8, 10],
29
+ [3, 6, 9, 12, 15]
30
+ ]
31
+
32
+ worksheet.write('A1', data)
33
+
34
+ chart.add_series(
35
+ :categories => '=Sheet1!$A$1:$A$5',
36
+ :values => '=Sheet1!$B$1:$B$5',
37
+ :smooth => 1
38
+ )
39
+
40
+ chart.add_series(
41
+ :categories => '=Sheet1!$A$1:$A$5',
42
+ :values => '=Sheet1!$C$1:$C$5'
43
+ )
44
+
45
+ worksheet.insert_chart('E9', chart)
46
+
47
+ workbook.close
48
+
49
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
50
+ # @xlsx,
51
+ # nil,
52
+ # {
53
+ # 'xl/charts/chart1.xml' => ['<c:pageMargins'],
54
+ # 'xl/workbook.xml' => [ '<fileVersion', '<calcPr' ]
55
+ # }
56
+ # )
57
+
58
+ end
59
+ end
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionImage09 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_image09
14
+ @xlsx = 'image09.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.insert_image('E9',
19
+ 'test/regression/images/red_64x20.png')
20
+
21
+ workbook.close
22
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
23
+ end
24
+ end
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionSetColumn01 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_set_column01
14
+ @xlsx = 'set_column01.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.set_column( "A:A", 0.08 )
19
+ worksheet.set_column( "B:B", 0.17 )
20
+ worksheet.set_column( "C:C", 0.25 )
21
+ worksheet.set_column( "D:D", 0.33 )
22
+ worksheet.set_column( "E:E", 0.42 )
23
+ worksheet.set_column( "F:F", 0.5 )
24
+ worksheet.set_column( "G:G", 0.58 )
25
+ worksheet.set_column( "H:H", 0.67 )
26
+ worksheet.set_column( "I:I", 0.75 )
27
+ worksheet.set_column( "J:J", 0.83 )
28
+ worksheet.set_column( "K:K", 0.92 )
29
+ worksheet.set_column( "L:L", 1 )
30
+ worksheet.set_column( "M:M", 1.14 )
31
+ worksheet.set_column( "N:N", 1.29 )
32
+ worksheet.set_column( "O:O", 1.43 )
33
+ worksheet.set_column( "P:P", 1.57 )
34
+ worksheet.set_column( "Q:Q", 1.71 )
35
+ worksheet.set_column( "R:R", 1.86 )
36
+ worksheet.set_column( "S:S", 2 )
37
+ worksheet.set_column( "T:T", 2.14 )
38
+ worksheet.set_column( "U:U", 2.29 )
39
+ worksheet.set_column( "V:V", 2.43 )
40
+ worksheet.set_column( "W:W", 2.57 )
41
+ worksheet.set_column( "X:X", 2.71 )
42
+ worksheet.set_column( "Y:Y", 2.86 )
43
+ worksheet.set_column( "Z:Z", 3 )
44
+ worksheet.set_column( "AB:AB", 8.57 )
45
+ worksheet.set_column( "AC:AC", 8.71 )
46
+ worksheet.set_column( "AD:AD", 8.86 )
47
+ worksheet.set_column( "AE:AE", 9 )
48
+ worksheet.set_column( "AF:AF", 9.14 )
49
+ worksheet.set_column( "AG:AG", 9.29 )
50
+
51
+ workbook.close
52
+
53
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
54
+ # @xlsx,
55
+ # nil,
56
+ # {
57
+ # 'xl/charts/chart1.xml' => ['<c:pageMargins'],
58
+ # 'xl/workbook.xml' => [ '<fileVersion', '<calcPr' ]
59
+ # }
60
+ # )
61
+
62
+ end
63
+ end
@@ -0,0 +1,64 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionSetColumn02 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_set_column02
14
+ @xlsx = 'set_column01.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ # Test widths with higher precision.
19
+ worksheet.set_column( "A:A", 0.083333333333333 )
20
+ worksheet.set_column( "B:B", 0.166666666666667 )
21
+ worksheet.set_column( "C:C", 0.250000000000000 )
22
+ worksheet.set_column( "D:D", 0.333333333333333 )
23
+ worksheet.set_column( "E:E", 0.416666666666667 )
24
+ worksheet.set_column( "F:F", 0.500000000000000 )
25
+ worksheet.set_column( "G:G", 0.583333333333333 )
26
+ worksheet.set_column( "H:H", 0.666666666666666 )
27
+ worksheet.set_column( "I:I", 0.750000000000000 )
28
+ worksheet.set_column( "J:J", 0.833333333333333 )
29
+ worksheet.set_column( "K:K", 0.916666666666666 )
30
+ worksheet.set_column( "L:L", 1.000000000000000 )
31
+ worksheet.set_column( "M:M", 1.142857142857140 )
32
+ worksheet.set_column( "N:N", 1.285714285714290 )
33
+ worksheet.set_column( "O:O", 1.428571428571430 )
34
+ worksheet.set_column( "P:P", 1.571428571428570 )
35
+ worksheet.set_column( "Q:Q", 1.714285714285710 )
36
+ worksheet.set_column( "R:R", 1.857142857142860 )
37
+ worksheet.set_column( "S:S", 2.000000000000000 )
38
+ worksheet.set_column( "T:T", 2.142857142857140 )
39
+ worksheet.set_column( "U:U", 2.285714285714290 )
40
+ worksheet.set_column( "V:V", 2.428571428571430 )
41
+ worksheet.set_column( "W:W", 2.571428571428570 )
42
+ worksheet.set_column( "X:X", 2.714285714285710 )
43
+ worksheet.set_column( "Y:Y", 2.857142857142860 )
44
+ worksheet.set_column( "Z:Z", 3.000000000000000 )
45
+ worksheet.set_column( "AB:AB", 8.571428571428570 )
46
+ worksheet.set_column( "AC:AC", 8.711428571428570 )
47
+ worksheet.set_column( "AD:AD", 8.857142857142860 )
48
+ worksheet.set_column( "AE:AE", 9.000000000000000 )
49
+ worksheet.set_column( "AF:AF", 9.142857142857140 )
50
+ worksheet.set_column( "AG:AG", 9.285714285714290 )
51
+
52
+ workbook.close
53
+
54
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
55
+ # @xlsx,
56
+ # nil,
57
+ # {
58
+ # 'xl/charts/chart1.xml' => ['<c:pageMargins'],
59
+ # 'xl/workbook.xml' => [ '<fileVersion', '<calcPr' ]
60
+ # }
61
+ # )
62
+
63
+ end
64
+ end
@@ -18,7 +18,7 @@ def test_position_object_emus_01
18
18
  def test_position_object_emus_02
19
19
  @worksheet.set_column('L:L', 3.86)
20
20
  result = @worksheet.__send__("position_object_emus", 4, 8, 0, 0, 480, 288)
21
- expected = [4, 8, 0, 0, 11, 22, 0, 76200, 2438400, 1524000]
21
+ expected = [4, 8, 0, 0, 12, 22, 0, 76200, 2438400, 1524000]
22
22
  assert_equal(expected, result)
23
23
  end
24
24
 
@@ -26,7 +26,7 @@ def test_position_object_emus_03
26
26
  @worksheet.set_column('L:L', 3.86)
27
27
  @worksheet.set_row(22, 6)
28
28
  result = @worksheet.__send__("position_object_emus", 4, 8, 0, 0, 480, 288)
29
- expected = [4, 8, 0, 0, 11, 22, 0, 0, 2438400, 1524000]
29
+ expected = [4, 8, 0, 0, 12, 23, 0, 0, 2438400, 1524000]
30
30
  assert_equal(expected, result)
31
31
  end
32
32
 
data/write_xlsx.gemspec CHANGED
@@ -23,5 +23,6 @@ Gem::Specification.new do |gem|
23
23
  ]
24
24
 
25
25
  gem.add_runtime_dependency(%q<rubyzip>, [">= 0"])
26
+ gem.add_development_dependency(%q<simplecov>) if RUBY_VERSION >= "1.9"
26
27
  end
27
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: write_xlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.69.0
4
+ version: 0.70.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hideo NAKAMURA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-29 00:00:00.000000000 Z
11
+ date: 2013-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: |
28
42
  write_xlsx s a gem to create a new file in the Excel 2007+ XLSX format, and you can use the same interface as writeexcel gem.
29
43
  The WriteXLSX supports the following features:
@@ -351,6 +365,7 @@ files:
351
365
  - test/regression/images/red.bmp
352
366
  - test/regression/images/red.jpg
353
367
  - test/regression/images/red.png
368
+ - test/regression/images/red_64x20.png
354
369
  - test/regression/images/yellow.jpg
355
370
  - test/regression/images/yellow.png
356
371
  - test/regression/test_array_formula01.rb
@@ -497,6 +512,8 @@ files:
497
512
  - test/regression/test_chart_gridlines09.rb
498
513
  - test/regression/test_chart_line01.rb
499
514
  - test/regression/test_chart_line02.rb
515
+ - test/regression/test_chart_line03.rb
516
+ - test/regression/test_chart_line04.rb
500
517
  - test/regression/test_chart_name01.rb
501
518
  - test/regression/test_chart_name02.rb
502
519
  - test/regression/test_chart_name03.rb
@@ -521,6 +538,9 @@ files:
521
538
  - test/regression/test_chart_scatter06.rb
522
539
  - test/regression/test_chart_scatter07.rb
523
540
  - test/regression/test_chart_scatter08.rb
541
+ - test/regression/test_chart_scatter09.rb
542
+ - test/regression/test_chart_scatter10.rb
543
+ - test/regression/test_chart_scatter11.rb
524
544
  - test/regression/test_chart_size01.rb
525
545
  - test/regression/test_chart_size02.rb
526
546
  - test/regression/test_chart_size03.rb
@@ -619,6 +639,7 @@ files:
619
639
  - test/regression/test_image06.rb
620
640
  - test/regression/test_image07.rb
621
641
  - test/regression/test_image08.rb
642
+ - test/regression/test_image09.rb
622
643
  - test/regression/test_macro01.rb
623
644
  - test/regression/test_outline01.rb
624
645
  - test/regression/test_outline02.rb
@@ -687,6 +708,8 @@ files:
687
708
  - test/regression/test_row_col_format14.rb
688
709
  - test/regression/test_selection01.rb
689
710
  - test/regression/test_selection02.rb
711
+ - test/regression/test_set_column01.rb
712
+ - test/regression/test_set_column02.rb
690
713
  - test/regression/test_set_print_scale01.rb
691
714
  - test/regression/test_set_start_page01.rb
692
715
  - test/regression/test_shape01.rb
@@ -884,6 +907,8 @@ files:
884
907
  - test/regression/xlsx_files/chart_gridlines09.xlsx
885
908
  - test/regression/xlsx_files/chart_line01.xlsx
886
909
  - test/regression/xlsx_files/chart_line02.xlsx
910
+ - test/regression/xlsx_files/chart_line03.xlsx
911
+ - test/regression/xlsx_files/chart_line04.xlsx
887
912
  - test/regression/xlsx_files/chart_name01.xlsx
888
913
  - test/regression/xlsx_files/chart_name02.xlsx
889
914
  - test/regression/xlsx_files/chart_name03.xlsx
@@ -907,6 +932,9 @@ files:
907
932
  - test/regression/xlsx_files/chart_scatter06.xlsx
908
933
  - test/regression/xlsx_files/chart_scatter07.xlsx
909
934
  - test/regression/xlsx_files/chart_scatter08.xlsx
935
+ - test/regression/xlsx_files/chart_scatter09.xlsx
936
+ - test/regression/xlsx_files/chart_scatter10.xlsx
937
+ - test/regression/xlsx_files/chart_scatter11.xlsx
910
938
  - test/regression/xlsx_files/chart_size01.xlsx
911
939
  - test/regression/xlsx_files/chart_sparse01.xlsx
912
940
  - test/regression/xlsx_files/chart_stock01.xlsx
@@ -1005,6 +1033,7 @@ files:
1005
1033
  - test/regression/xlsx_files/image06.xlsx
1006
1034
  - test/regression/xlsx_files/image07.xlsx
1007
1035
  - test/regression/xlsx_files/image08.xlsx
1036
+ - test/regression/xlsx_files/image09.xlsx
1008
1037
  - test/regression/xlsx_files/macro01.xlsm
1009
1038
  - test/regression/xlsx_files/outline01.xlsx
1010
1039
  - test/regression/xlsx_files/outline02.xlsx
@@ -1073,6 +1102,7 @@ files:
1073
1102
  - test/regression/xlsx_files/row_col_format14.xlsx
1074
1103
  - test/regression/xlsx_files/selection01.xlsx
1075
1104
  - test/regression/xlsx_files/selection02.xlsx
1105
+ - test/regression/xlsx_files/set_column01.xlsx
1076
1106
  - test/regression/xlsx_files/set_print_scale01.xlsx
1077
1107
  - test/regression/xlsx_files/set_start_page01.xlsx
1078
1108
  - test/regression/xlsx_files/shape01.xlsx
@@ -1435,6 +1465,7 @@ test_files:
1435
1465
  - test/regression/images/red.bmp
1436
1466
  - test/regression/images/red.jpg
1437
1467
  - test/regression/images/red.png
1468
+ - test/regression/images/red_64x20.png
1438
1469
  - test/regression/images/yellow.jpg
1439
1470
  - test/regression/images/yellow.png
1440
1471
  - test/regression/test_array_formula01.rb
@@ -1581,6 +1612,8 @@ test_files:
1581
1612
  - test/regression/test_chart_gridlines09.rb
1582
1613
  - test/regression/test_chart_line01.rb
1583
1614
  - test/regression/test_chart_line02.rb
1615
+ - test/regression/test_chart_line03.rb
1616
+ - test/regression/test_chart_line04.rb
1584
1617
  - test/regression/test_chart_name01.rb
1585
1618
  - test/regression/test_chart_name02.rb
1586
1619
  - test/regression/test_chart_name03.rb
@@ -1605,6 +1638,9 @@ test_files:
1605
1638
  - test/regression/test_chart_scatter06.rb
1606
1639
  - test/regression/test_chart_scatter07.rb
1607
1640
  - test/regression/test_chart_scatter08.rb
1641
+ - test/regression/test_chart_scatter09.rb
1642
+ - test/regression/test_chart_scatter10.rb
1643
+ - test/regression/test_chart_scatter11.rb
1608
1644
  - test/regression/test_chart_size01.rb
1609
1645
  - test/regression/test_chart_size02.rb
1610
1646
  - test/regression/test_chart_size03.rb
@@ -1703,6 +1739,7 @@ test_files:
1703
1739
  - test/regression/test_image06.rb
1704
1740
  - test/regression/test_image07.rb
1705
1741
  - test/regression/test_image08.rb
1742
+ - test/regression/test_image09.rb
1706
1743
  - test/regression/test_macro01.rb
1707
1744
  - test/regression/test_outline01.rb
1708
1745
  - test/regression/test_outline02.rb
@@ -1771,6 +1808,8 @@ test_files:
1771
1808
  - test/regression/test_row_col_format14.rb
1772
1809
  - test/regression/test_selection01.rb
1773
1810
  - test/regression/test_selection02.rb
1811
+ - test/regression/test_set_column01.rb
1812
+ - test/regression/test_set_column02.rb
1774
1813
  - test/regression/test_set_print_scale01.rb
1775
1814
  - test/regression/test_set_start_page01.rb
1776
1815
  - test/regression/test_shape01.rb
@@ -1968,6 +2007,8 @@ test_files:
1968
2007
  - test/regression/xlsx_files/chart_gridlines09.xlsx
1969
2008
  - test/regression/xlsx_files/chart_line01.xlsx
1970
2009
  - test/regression/xlsx_files/chart_line02.xlsx
2010
+ - test/regression/xlsx_files/chart_line03.xlsx
2011
+ - test/regression/xlsx_files/chart_line04.xlsx
1971
2012
  - test/regression/xlsx_files/chart_name01.xlsx
1972
2013
  - test/regression/xlsx_files/chart_name02.xlsx
1973
2014
  - test/regression/xlsx_files/chart_name03.xlsx
@@ -1991,6 +2032,9 @@ test_files:
1991
2032
  - test/regression/xlsx_files/chart_scatter06.xlsx
1992
2033
  - test/regression/xlsx_files/chart_scatter07.xlsx
1993
2034
  - test/regression/xlsx_files/chart_scatter08.xlsx
2035
+ - test/regression/xlsx_files/chart_scatter09.xlsx
2036
+ - test/regression/xlsx_files/chart_scatter10.xlsx
2037
+ - test/regression/xlsx_files/chart_scatter11.xlsx
1994
2038
  - test/regression/xlsx_files/chart_size01.xlsx
1995
2039
  - test/regression/xlsx_files/chart_sparse01.xlsx
1996
2040
  - test/regression/xlsx_files/chart_stock01.xlsx
@@ -2089,6 +2133,7 @@ test_files:
2089
2133
  - test/regression/xlsx_files/image06.xlsx
2090
2134
  - test/regression/xlsx_files/image07.xlsx
2091
2135
  - test/regression/xlsx_files/image08.xlsx
2136
+ - test/regression/xlsx_files/image09.xlsx
2092
2137
  - test/regression/xlsx_files/macro01.xlsm
2093
2138
  - test/regression/xlsx_files/outline01.xlsx
2094
2139
  - test/regression/xlsx_files/outline02.xlsx
@@ -2157,6 +2202,7 @@ test_files:
2157
2202
  - test/regression/xlsx_files/row_col_format14.xlsx
2158
2203
  - test/regression/xlsx_files/selection01.xlsx
2159
2204
  - test/regression/xlsx_files/selection02.xlsx
2205
+ - test/regression/xlsx_files/set_column01.xlsx
2160
2206
  - test/regression/xlsx_files/set_print_scale01.xlsx
2161
2207
  - test/regression/xlsx_files/set_start_page01.xlsx
2162
2208
  - test/regression/xlsx_files/shape01.xlsx