writeexcel 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -0
- data/VERSION +1 -1
- data/examples/chess.rb +141 -0
- data/examples/colors.rb +128 -0
- data/examples/comments1.rb +26 -0
- data/examples/comments2.rb +351 -0
- data/lib/writeexcel/worksheet.rb +30 -36
- data/test/perl_output/chess.xls +0 -0
- data/test/perl_output/colors.xls +0 -0
- data/test/perl_output/comments1.xls +0 -0
- data/test/perl_output/comments2.xls +0 -0
- data/test/test_example_match.rb +589 -1
- data/writeexcel.gemspec +14 -2
- metadata +15 -3
data/lib/writeexcel/worksheet.rb
CHANGED
@@ -3559,7 +3559,7 @@ class Worksheet < BIFFWriter
|
|
3559
3559
|
col = args[1]
|
3560
3560
|
|
3561
3561
|
# Check for pairs of optional arguments, i.e. an odd number of args.
|
3562
|
-
raise "Uneven number of additional arguments" if args.size % 2 == 0
|
3562
|
+
# raise "Uneven number of additional arguments" if args.size % 2 == 0
|
3563
3563
|
|
3564
3564
|
# Check that row and col are valid and store max and min values
|
3565
3565
|
return -2 if check_dimensions(row, col) != 0
|
@@ -7204,6 +7204,11 @@ class Worksheet < BIFFWriter
|
|
7204
7204
|
end
|
7205
7205
|
private :store_filters
|
7206
7206
|
|
7207
|
+
def unpack_record(data)
|
7208
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
7209
|
+
end
|
7210
|
+
private :unpack_record
|
7211
|
+
|
7207
7212
|
###############################################################################
|
7208
7213
|
#
|
7209
7214
|
# _store_comments()
|
@@ -7221,7 +7226,7 @@ class Worksheet < BIFFWriter
|
|
7221
7226
|
spid = ids.shift
|
7222
7227
|
|
7223
7228
|
comments = @comments_array
|
7224
|
-
num_comments =
|
7229
|
+
num_comments = comments.size
|
7225
7230
|
|
7226
7231
|
# Number of objects written so far.
|
7227
7232
|
num_objects = @images_array.size + @filter_count + @charts_array.size
|
@@ -7241,7 +7246,7 @@ class Worksheet < BIFFWriter
|
|
7241
7246
|
str_len = str_len / 2 if encoding != 0 # Num of chars not bytes.
|
7242
7247
|
formats = [[0, 9], [str_len, 0]]
|
7243
7248
|
|
7244
|
-
if i == 0 and num_objects
|
7249
|
+
if i == 0 and num_objects == 0
|
7245
7250
|
# Write the parent MSODRAWIING record.
|
7246
7251
|
dg_length = 200 + 128*(num_comments -1)
|
7247
7252
|
spgr_length = 176 + 128*(num_comments -1)
|
@@ -7252,27 +7257,22 @@ class Worksheet < BIFFWriter
|
|
7252
7257
|
store_mso_sp_container(40) +
|
7253
7258
|
store_mso_spgr() +
|
7254
7259
|
store_mso_sp(0x0, spid, 0x0005)
|
7255
|
-
spid
|
7256
|
-
data = data + store_mso_sp_container(120) +
|
7257
|
-
store_mso_sp(202, spid, 0x0A00) +
|
7258
|
-
store_mso_opt_comment(0x80, visible, color) +
|
7259
|
-
store_mso_client_anchor(3, *vertices) +
|
7260
|
-
store_mso_client_data()
|
7261
|
-
spid = spid + 1
|
7262
|
-
|
7260
|
+
spid += 1
|
7263
7261
|
else
|
7264
|
-
|
7265
|
-
data = store_mso_sp_container(120) +
|
7266
|
-
store_mso_sp(202, spid, 0x0A00) +
|
7267
|
-
store_mso_opt_comment(0x80, visible, color) +
|
7268
|
-
store_mso_client_anchor(3, *vertices) +
|
7269
|
-
store_mso_client_data()
|
7270
|
-
spid = spid + 1
|
7262
|
+
data = ''
|
7271
7263
|
end
|
7264
|
+
data +=
|
7265
|
+
store_mso_sp_container(120) +
|
7266
|
+
store_mso_sp(202, spid, 0x0A00)
|
7267
|
+
spid += 1
|
7268
|
+
data +=
|
7269
|
+
store_mso_opt_comment(0x80, visible, color) +
|
7270
|
+
store_mso_client_anchor(3, *vertices) +
|
7271
|
+
store_mso_client_data
|
7272
7272
|
length = data.length
|
7273
7273
|
header = [record, length].pack("vv")
|
7274
7274
|
print "sheet #{@name} : #{__FILE__}(#{__LINE__})\n" if defined?($debug)
|
7275
|
-
append(
|
7275
|
+
append(header, data)
|
7276
7276
|
|
7277
7277
|
store_obj_comment(num_objects + i + 1)
|
7278
7278
|
store_mso_drawing_text_box()
|
@@ -7409,8 +7409,8 @@ class Worksheet < BIFFWriter
|
|
7409
7409
|
# Use the visible flag if set by the user or else use the worksheet value.
|
7410
7410
|
# Note that the value used is the opposite of _store_note().
|
7411
7411
|
#
|
7412
|
-
|
7413
|
-
visible = visible ? 0x0000 : 0x0002
|
7412
|
+
if !visible.nil?
|
7413
|
+
visible = visible != 0 ? 0x0000 : 0x0002
|
7414
7414
|
else
|
7415
7415
|
visible = @comments_visible != 0 ? 0x0000 : 0x0002
|
7416
7416
|
end
|
@@ -7912,7 +7912,7 @@ class Worksheet < BIFFWriter
|
|
7912
7912
|
# Use the visible flag if set by the user or else use the worksheet value.
|
7913
7913
|
# The flag is also set in _store_mso_opt_comment() but with the opposite
|
7914
7914
|
# value.
|
7915
|
-
|
7915
|
+
if !visible.nil?
|
7916
7916
|
visible = visible != 0 ? 0x0002 : 0x0000
|
7917
7917
|
else
|
7918
7918
|
visible = @comments_visible != 0 ? 0x0002 : 0x0000
|
@@ -7923,8 +7923,7 @@ class Worksheet < BIFFWriter
|
|
7923
7923
|
num_chars = num_chars / 2 if author_enc != 0 && !author_enc.nil?
|
7924
7924
|
|
7925
7925
|
# Null terminate the author string.
|
7926
|
-
author
|
7927
|
-
|
7926
|
+
author += "\0"
|
7928
7927
|
|
7929
7928
|
# Pack the record.
|
7930
7929
|
data = [row, col, visible, obj_id, num_chars, author_enc].pack("vvvvvC")
|
@@ -7979,21 +7978,18 @@ class Worksheet < BIFFWriter
|
|
7979
7978
|
|
7980
7979
|
# Change from UTF-16BE to UTF-16LE
|
7981
7980
|
string = string.unpack('n*').pack('v*')
|
7981
|
+
# Handle utf8 strings
|
7982
|
+
elsif string =~ NonAscii
|
7983
|
+
string = NKF.nkf('-w16L0 -m0 -W', string)
|
7984
|
+
params[:encoding] = 1
|
7982
7985
|
end
|
7983
7986
|
|
7984
7987
|
if params[:author_encoding] != 0
|
7985
|
-
raise "Uneven number of bytes in author string" if params[:author] % 2 != 0
|
7988
|
+
raise "Uneven number of bytes in author string" if params[:author].length % 2 != 0
|
7986
7989
|
|
7987
7990
|
# Change from UTF-16BE to UTF-16LE
|
7988
7991
|
params[:author] = params[:author].unpack('n*').pack('v*')
|
7989
|
-
|
7990
|
-
|
7991
|
-
# Handle utf8 strings
|
7992
|
-
if string =~ NonAscii
|
7993
|
-
string = NKF.nkf('-w16L0 -m0 -W', string)
|
7994
|
-
params[:encoding] = 1
|
7995
|
-
end
|
7996
|
-
if params[:author] =~ NonAscii
|
7992
|
+
elsif params[:author] =~ NonAscii
|
7997
7993
|
params[:author] = NKF.nkf('-w16L0 -m0 -W', params[:author])
|
7998
7994
|
params[:author_encoding] = 1
|
7999
7995
|
end
|
@@ -8014,9 +8010,7 @@ class Worksheet < BIFFWriter
|
|
8014
8010
|
|
8015
8011
|
# Convert a cell reference to a row and column.
|
8016
8012
|
unless params[:start_cell].nil?
|
8017
|
-
|
8018
|
-
params[:start_row] = row
|
8019
|
-
params[:start_col] = col
|
8013
|
+
params[:start_row], params[:start_col] = substitute_cellref(params[:start_cell])
|
8020
8014
|
end
|
8021
8015
|
|
8022
8016
|
# Set the default start cell and offsets for the comment. These are
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|