write_xlsx 0.72.1 → 0.72.2
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 +4 -4
- data/README.rdoc +3 -0
- data/lib/write_xlsx/package/app.rb +17 -18
- data/lib/write_xlsx/package/comments.rb +0 -2
- data/lib/write_xlsx/package/content_types.rb +5 -6
- data/lib/write_xlsx/package/core.rb +22 -29
- data/lib/write_xlsx/package/shared_strings.rb +2 -6
- data/lib/write_xlsx/package/styles.rb +13 -13
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +24 -2
- data/test/helper.rb +1 -1
- data/write_xlsx.gemspec +1 -1
- metadata +5 -7
- data/lib/write_xlsx/zip_file_utils.rb +0 -98
- data/test/package/shared_strings/test_write_sst.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66ec26ddd5f837ef4d832d0efea345aaf5fdc524
|
4
|
+
data.tar.gz: e3e5c86594dd02a88a0dd3c18a018ff28b261ba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5115cdfdcbfc75c4fdd51d14898b288ee0e17dde96156ce73319bd947683243e5ffb44ef7aaad674f3798f9f0b3dd9a2b3b4e74aa6e59248942464dd8ef8c28a
|
7
|
+
data.tar.gz: 3360712655ad5a43349666c8c7e7b9e76aafb0e5ea3cfec89785b5b3f7df087c485f6d463688a991855dfe486be3d1b810a77a86fec86f2e62b1dc985cf9230b
|
data/README.rdoc
CHANGED
@@ -21,20 +21,19 @@ module Writexlsx
|
|
21
21
|
|
22
22
|
def assemble_xml_file
|
23
23
|
write_xml_declaration
|
24
|
-
write_properties
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
@writer.end_tag('Properties')
|
24
|
+
write_properties do
|
25
|
+
write_application
|
26
|
+
write_doc_security
|
27
|
+
write_scale_crop
|
28
|
+
write_heading_pairs
|
29
|
+
write_titles_of_parts
|
30
|
+
write_manager
|
31
|
+
write_company
|
32
|
+
write_links_up_to_date
|
33
|
+
write_shared_doc
|
34
|
+
write_hyperlinks_changed
|
35
|
+
write_app_version
|
36
|
+
end
|
38
37
|
@writer.crlf
|
39
38
|
@writer.close
|
40
39
|
end
|
@@ -66,13 +65,15 @@ module Writexlsx
|
|
66
65
|
# Write the <Properties> element.
|
67
66
|
#
|
68
67
|
def write_properties
|
68
|
+
tag = 'Properties'
|
69
|
+
|
69
70
|
schema = 'http://schemas.openxmlformats.org/officeDocument/2006/'
|
70
71
|
attributes = [
|
71
72
|
'xmlns', "#{schema}extended-properties",
|
72
73
|
'xmlns:vt', "#{schema}docPropsVTypes"
|
73
74
|
]
|
74
75
|
|
75
|
-
@writer.
|
76
|
+
@writer.tag_elements('Properties', attributes) { yield }
|
76
77
|
end
|
77
78
|
|
78
79
|
#
|
@@ -125,10 +126,8 @@ module Writexlsx
|
|
125
126
|
# Write the <vt:vector> element.
|
126
127
|
#
|
127
128
|
def write_vt_vector(base_type, data)
|
128
|
-
size = data.size
|
129
|
-
|
130
129
|
attributes = [
|
131
|
-
'size', size,
|
130
|
+
'size', data.size,
|
132
131
|
'baseType', base_type
|
133
132
|
]
|
134
133
|
|
@@ -32,11 +32,10 @@ module Writexlsx
|
|
32
32
|
|
33
33
|
def assemble_xml_file
|
34
34
|
write_xml_declaration
|
35
|
-
write_types
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@writer.end_tag('Types')
|
35
|
+
write_types do
|
36
|
+
write_defaults
|
37
|
+
write_overrides
|
38
|
+
end
|
40
39
|
@writer.crlf
|
41
40
|
@writer.close
|
42
41
|
end
|
@@ -185,7 +184,7 @@ module Writexlsx
|
|
185
184
|
xmlns = 'http://schemas.openxmlformats.org/package/2006/content-types'
|
186
185
|
attributes = ['xmlns', xmlns]
|
187
186
|
|
188
|
-
@writer.
|
187
|
+
@writer.tag_elements('Types', attributes) { yield }
|
189
188
|
end
|
190
189
|
|
191
190
|
#
|
@@ -23,19 +23,18 @@ module Writexlsx
|
|
23
23
|
|
24
24
|
def assemble_xml_file
|
25
25
|
write_xml_declaration
|
26
|
-
write_cp_core_properties
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
@writer.end_tag('cp:coreProperties')
|
26
|
+
write_cp_core_properties do
|
27
|
+
write_dc_title
|
28
|
+
write_dc_subject
|
29
|
+
write_dc_creator
|
30
|
+
write_cp_keywords
|
31
|
+
write_dc_description
|
32
|
+
write_cp_last_modified_by
|
33
|
+
write_dcterms_created
|
34
|
+
write_dcterms_modified
|
35
|
+
write_cp_category
|
36
|
+
write_cp_content_status
|
37
|
+
end
|
39
38
|
@writer.crlf
|
40
39
|
@writer.close
|
41
40
|
end
|
@@ -52,7 +51,7 @@ module Writexlsx
|
|
52
51
|
def localtime_to_iso8601_date(local_time = nil)
|
53
52
|
local_time ||= Time.now
|
54
53
|
|
55
|
-
|
54
|
+
local_time.strftime('%Y-%m-%dT%H:%M:%SZ')
|
56
55
|
end
|
57
56
|
|
58
57
|
def write_xml_declaration
|
@@ -77,7 +76,7 @@ module Writexlsx
|
|
77
76
|
'xmlns:xsi', xmlns_xsi
|
78
77
|
]
|
79
78
|
|
80
|
-
@writer.
|
79
|
+
@writer.tag_elements('cp:coreProperties', attributes) { yield }
|
81
80
|
end
|
82
81
|
|
83
82
|
#
|
@@ -98,28 +97,22 @@ module Writexlsx
|
|
98
97
|
# Write the <dcterms:created> element.
|
99
98
|
#
|
100
99
|
def write_dcterms_created
|
101
|
-
|
102
|
-
xsi_type = 'dcterms:W3CDTF'
|
103
|
-
|
104
|
-
date = localtime_to_iso8601_date(date)
|
105
|
-
|
106
|
-
attributes = ['xsi:type', xsi_type]
|
107
|
-
|
108
|
-
@writer.data_element('dcterms:created', date, attributes)
|
100
|
+
write_dcterms('dcterms:created')
|
109
101
|
end
|
110
102
|
|
111
103
|
#
|
112
104
|
# Write the <dcterms:modified> element.
|
113
105
|
#
|
114
106
|
def write_dcterms_modified
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
date = localtime_to_iso8601_date(date)
|
107
|
+
write_dcterms('dcterms:modified')
|
108
|
+
end
|
119
109
|
|
120
|
-
|
110
|
+
def write_dcterms(tag)
|
111
|
+
@writer.data_element(tag, dcterms_date, ['xsi:type', 'dcterms:W3CDTF'])
|
112
|
+
end
|
121
113
|
|
122
|
-
|
114
|
+
def dcterms_date
|
115
|
+
localtime_to_iso8601_date(@properties[:created])
|
123
116
|
end
|
124
117
|
|
125
118
|
#
|
@@ -45,13 +45,9 @@ module Writexlsx
|
|
45
45
|
write_xml_declaration
|
46
46
|
|
47
47
|
# Write the sst table.
|
48
|
-
write_sst
|
49
|
-
|
50
|
-
# Write the sst strings.
|
51
|
-
write_sst_strings
|
48
|
+
write_sst { write_sst_strings }
|
52
49
|
|
53
50
|
# Close the sst tag.
|
54
|
-
@writer.end_tag('sst')
|
55
51
|
@writer.crlf
|
56
52
|
@writer.close
|
57
53
|
end
|
@@ -75,7 +71,7 @@ module Writexlsx
|
|
75
71
|
'uniqueCount', unique_count
|
76
72
|
]
|
77
73
|
|
78
|
-
@writer.
|
74
|
+
@writer.tag_elements('sst', attributes) { yield }
|
79
75
|
end
|
80
76
|
|
81
77
|
#
|
@@ -26,18 +26,18 @@ module Writexlsx
|
|
26
26
|
|
27
27
|
def assemble_xml_file
|
28
28
|
write_xml_declaration
|
29
|
-
write_style_sheet
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
29
|
+
write_style_sheet do
|
30
|
+
write_num_fmts
|
31
|
+
write_fonts
|
32
|
+
write_fills
|
33
|
+
write_borders
|
34
|
+
write_cell_style_xfs
|
35
|
+
write_cell_xfs
|
36
|
+
write_cell_styles
|
37
|
+
write_dxfs
|
38
|
+
write_table_styles
|
39
|
+
write_colors
|
40
|
+
end
|
41
41
|
@writer.crlf
|
42
42
|
@writer.close
|
43
43
|
end
|
@@ -83,7 +83,7 @@ module Writexlsx
|
|
83
83
|
|
84
84
|
attributes = ['xmlns', xmlns]
|
85
85
|
|
86
|
-
@writer.
|
86
|
+
@writer.tag_elements('styleSheet', attributes) { yield }
|
87
87
|
end
|
88
88
|
|
89
89
|
#
|
data/lib/write_xlsx/version.rb
CHANGED
data/lib/write_xlsx/workbook.rb
CHANGED
@@ -9,10 +9,10 @@ require 'write_xlsx/format'
|
|
9
9
|
require 'write_xlsx/shape'
|
10
10
|
require 'write_xlsx/utility'
|
11
11
|
require 'write_xlsx/chart'
|
12
|
-
require 'write_xlsx/zip_file_utils'
|
13
12
|
require 'tmpdir'
|
14
13
|
require 'tempfile'
|
15
14
|
require 'digest/md5'
|
15
|
+
require 'zip'
|
16
16
|
|
17
17
|
module Writexlsx
|
18
18
|
|
@@ -1223,11 +1223,33 @@ module Writexlsx
|
|
1223
1223
|
packager = nil
|
1224
1224
|
|
1225
1225
|
# Store the xlsx component files with the temp dir name removed.
|
1226
|
-
|
1226
|
+
# See https://github.com/randym/axlsx
|
1227
|
+
Zip::OutputStream.open(@filename) do |zip|
|
1228
|
+
write_parts(zip)
|
1229
|
+
end
|
1230
|
+
|
1227
1231
|
IO.copy_stream(@filename, @fileobj) if @fileobj
|
1228
1232
|
Writexlsx::Utility.delete_files(@tempdir)
|
1229
1233
|
end
|
1230
1234
|
|
1235
|
+
def write_parts(zip)
|
1236
|
+
parts.each do |part|
|
1237
|
+
zip.put_next_entry(zip_entry_for_part(part.sub(Regexp.new("#{@tempdir}/?"), '')))
|
1238
|
+
zip.puts(File.read(part))
|
1239
|
+
end
|
1240
|
+
end
|
1241
|
+
|
1242
|
+
def zip_entry_for_part(part)
|
1243
|
+
Zip::Entry.new("", part)
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
#
|
1247
|
+
# files
|
1248
|
+
#
|
1249
|
+
def parts
|
1250
|
+
Dir.glob(File.join(@tempdir, "**", "*"), File::FNM_DOTMATCH).select {|f| File.file?(f)}
|
1251
|
+
end
|
1252
|
+
|
1231
1253
|
#
|
1232
1254
|
# Prepare all of the format properties prior to passing them to Styles.rb.
|
1233
1255
|
#
|
data/test/helper.rb
CHANGED
data/write_xlsx.gemspec
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: write_xlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.72.
|
4
|
+
version: 0.72.2
|
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-09-
|
11
|
+
date: 2013-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -163,7 +163,6 @@ files:
|
|
163
163
|
- lib/write_xlsx/worksheet/data_validation.rb
|
164
164
|
- lib/write_xlsx/worksheet/hyperlink.rb
|
165
165
|
- lib/write_xlsx/worksheet/page_setup.rb
|
166
|
-
- lib/write_xlsx/zip_file_utils.rb
|
167
166
|
- test/chart/test_add_series.rb
|
168
167
|
- test/chart/test_process_names.rb
|
169
168
|
- test/chart/test_write_a_latin.rb
|
@@ -236,7 +235,6 @@ files:
|
|
236
235
|
- test/package/shared_strings/test_shared_strings01.rb
|
237
236
|
- test/package/shared_strings/test_shared_strings02.rb
|
238
237
|
- test/package/shared_strings/test_write_si.rb
|
239
|
-
- test/package/shared_strings/test_write_sst.rb
|
240
238
|
- test/package/styles/test_styles_01.rb
|
241
239
|
- test/package/styles/test_styles_02.rb
|
242
240
|
- test/package/styles/test_styles_03.rb
|
@@ -1376,7 +1374,6 @@ test_files:
|
|
1376
1374
|
- test/package/shared_strings/test_shared_strings01.rb
|
1377
1375
|
- test/package/shared_strings/test_shared_strings02.rb
|
1378
1376
|
- test/package/shared_strings/test_write_si.rb
|
1379
|
-
- test/package/shared_strings/test_write_sst.rb
|
1380
1377
|
- test/package/styles/test_styles_01.rb
|
1381
1378
|
- test/package/styles/test_styles_02.rb
|
1382
1379
|
- test/package/styles/test_styles_03.rb
|
@@ -2419,3 +2416,4 @@ test_files:
|
|
2419
2416
|
- test/worksheet/test_write_tab_color.rb
|
2420
2417
|
- test/worksheet/test_write_url.rb
|
2421
2418
|
- test/worksheet/test_write_worksheet_attributes.rb
|
2419
|
+
has_rdoc:
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# from http://d.hatena.ne.jp/alunko/20071021
|
4
|
-
#
|
5
|
-
require 'kconv'
|
6
|
-
require 'zip/zipfilesystem'
|
7
|
-
require 'fileutils'
|
8
|
-
|
9
|
-
module ZipFileUtils
|
10
|
-
|
11
|
-
# src file or directory
|
12
|
-
# dest zip filename
|
13
|
-
# options :fs_encoding=[UTF-8,Shift_JIS,EUC-JP]
|
14
|
-
def self.zip(src, dest, options = {})
|
15
|
-
src = File.expand_path(src)
|
16
|
-
dest = File.expand_path(dest)
|
17
|
-
File.unlink(dest) if File.exist?(dest)
|
18
|
-
Zip::ZipFile.open(dest, Zip::ZipFile::CREATE) {|zf|
|
19
|
-
if(File.file?(src))
|
20
|
-
zf.add(encode_path(File.basename(src), options[:fs_encoding]), src)
|
21
|
-
break
|
22
|
-
else
|
23
|
-
each_dir_for(src){ |path|
|
24
|
-
if File.file?(path)
|
25
|
-
zf.add(encode_path(relative(path, src), options[:fs_encoding]), path)
|
26
|
-
elsif File.directory?(path)
|
27
|
-
zf.mkdir(encode_path(relative(path, src), options[:fs_encoding]))
|
28
|
-
end
|
29
|
-
}
|
30
|
-
end
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
# src zip filename
|
35
|
-
# dest destination directory
|
36
|
-
# options :fs_encoding=[UTF-8,Shift_JIS,EUC-JP]
|
37
|
-
def self.unzip(src, dest, options = {})
|
38
|
-
FileUtils.makedirs(dest)
|
39
|
-
Zip::ZipInputStream.open(src){ |is|
|
40
|
-
loop do
|
41
|
-
entry = is.get_next_entry()
|
42
|
-
break if entry.nil?()
|
43
|
-
dir = File.dirname(entry.name)
|
44
|
-
FileUtils.makedirs(dest+ '/' + dir)
|
45
|
-
path = encode_path(dest + '/' + entry.name, options[:fs_encoding])
|
46
|
-
if(entry.file?())
|
47
|
-
File.open(path,
|
48
|
-
File::CREAT|File::WRONLY|File::BINARY) do |w|
|
49
|
-
w.puts(is.read())
|
50
|
-
end
|
51
|
-
else
|
52
|
-
FileUtils.makedirs(path)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
}
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
def self.each_dir_for(dir_path, &block)
|
60
|
-
dir = Dir.open(dir_path)
|
61
|
-
each_file_for(dir_path){ |file_path|
|
62
|
-
yield(file_path)
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.each_file_for(path, &block)
|
67
|
-
if File.file?(path)
|
68
|
-
yield(path)
|
69
|
-
return true
|
70
|
-
end
|
71
|
-
dir = Dir.open(path)
|
72
|
-
file_exist = false
|
73
|
-
dir.each(){ |file|
|
74
|
-
next if file == '.' || file == '..'
|
75
|
-
file_exist = true if each_file_for(path + "/" + file, &block)
|
76
|
-
}
|
77
|
-
yield(path) unless file_exist
|
78
|
-
return file_exist
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.relative(path, base_dir)
|
82
|
-
path[base_dir.length() + 1 .. path.length()] if path.index(base_dir) == 0
|
83
|
-
end
|
84
|
-
|
85
|
-
def self.encode_path(path, encode_s)
|
86
|
-
return path if encode_s.nil?()
|
87
|
-
case(encode_s)
|
88
|
-
when('UTF-8')
|
89
|
-
return path.toutf8()
|
90
|
-
when('Shift_JIS')
|
91
|
-
return path.tosjis()
|
92
|
-
when('EUC-JP')
|
93
|
-
return path.toeuc()
|
94
|
-
else
|
95
|
-
return path
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'helper'
|
3
|
-
require 'write_xlsx/package/shared_strings'
|
4
|
-
|
5
|
-
class TestWriteSst < Test::Unit::TestCase
|
6
|
-
def test_write_sst
|
7
|
-
@obj = Writexlsx::Package::SharedStrings.new
|
8
|
-
@obj.index('1')
|
9
|
-
@obj.index('2')
|
10
|
-
5.times { @obj.index('3') }
|
11
|
-
@obj.__send__('write_sst')
|
12
|
-
result = @obj.instance_variable_get(:@writer).string
|
13
|
-
expected = '<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="7" uniqueCount="3">'
|
14
|
-
assert_equal(expected, result)
|
15
|
-
end
|
16
|
-
end
|