axlsx 1.1.4 → 1.3.1

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.
Files changed (242) hide show
  1. data/.yardopts +6 -2
  2. data/CHANGELOG.md +72 -0
  3. data/README.md +114 -31
  4. data/Rakefile +11 -3
  5. data/examples/auto_filter.rb +16 -0
  6. data/examples/auto_filter.xlsx +0 -0
  7. data/examples/basic_charts.rb +58 -0
  8. data/examples/chart_colors.rb +17 -2
  9. data/examples/data_validation.rb +50 -0
  10. data/examples/example.rb +171 -60
  11. data/examples/example.xlsx +0 -0
  12. data/examples/example_streamed.xlsx +0 -0
  13. data/examples/extractive.pdf +0 -0
  14. data/examples/extractive.rb +3 -0
  15. data/examples/extractive.xlsx +0 -0
  16. data/examples/hyperlinks.rb +23 -0
  17. data/examples/hyperlinks.xlsx +0 -0
  18. data/examples/no-use_autowidth.xlsx +0 -0
  19. data/examples/page_setup.rb +11 -0
  20. data/examples/page_setup.xlsx +0 -0
  21. data/examples/scraping_html.rb +91 -0
  22. data/examples/shared_strings_example.xlsx +0 -0
  23. data/examples/sheet_protection.rb +10 -0
  24. data/examples/sheet_view.rb +34 -0
  25. data/examples/skydrive/axlsx.csv +1 -0
  26. data/examples/skydrive/axlsx.xlsx +0 -0
  27. data/examples/skydrive/real_example.rb +8 -8
  28. data/examples/sprk2012/Screen Shot 2012-09-11 at 10.42.06 PM.png +0 -0
  29. data/examples/sprk2012/Screen Shot 2012-09-11 at 11.07.48 PM.png +0 -0
  30. data/examples/sprk2012/Screen Shot 2012-09-11 at 8.31.50 PM.png +0 -0
  31. data/examples/sprk2012/Screen Shot 2012-09-11 at 9.23.27 PM.png +0 -0
  32. data/examples/sprk2012/Screen Shot 2012-09-11 at 9.32.06 PM.png +0 -0
  33. data/examples/sprk2012/Screen Shot 2012-09-11 at 9.33.35 PM.png +0 -0
  34. data/examples/sprk2012/Screen Shot 2012-09-11 at 9.46.44 PM.png +0 -0
  35. data/examples/sprk2012/Screen Shot 2012-09-12 at 5.07.23 PM.png +0 -0
  36. data/examples/sprk2012/basics.rb +11 -0
  37. data/examples/sprk2012/basics.xlsx +0 -0
  38. data/examples/sprk2012/gravatar.jpeg +0 -0
  39. data/examples/sprk2012/hair_club.jpg +0 -0
  40. data/examples/sprk2012/images.rb +9 -0
  41. data/examples/sprk2012/images.xlsx +0 -0
  42. data/examples/sprk2012/line_chart.rb +56 -0
  43. data/examples/sprk2012/line_chart.xlsx +0 -0
  44. data/examples/sprk2012/sprk2012.key +0 -0
  45. data/examples/sprk2012/styles.rb +20 -0
  46. data/examples/sprk2012/styles.xlsx +0 -0
  47. data/examples/styles.rb +62 -0
  48. data/examples/styles.xlsx +0 -0
  49. data/examples/two_cell_anchor_image.rb +11 -0
  50. data/lib/axlsx/content_type/content_type.rb +2 -0
  51. data/lib/axlsx/content_type/default.rb +30 -15
  52. data/lib/axlsx/content_type/override.rb +29 -14
  53. data/lib/axlsx/doc_props/app.rb +161 -104
  54. data/lib/axlsx/doc_props/core.rb +9 -5
  55. data/lib/axlsx/drawing/ax_data_source.rb +7 -6
  56. data/lib/axlsx/drawing/axis.rb +82 -36
  57. data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
  58. data/lib/axlsx/drawing/bar_series.rb +2 -1
  59. data/lib/axlsx/drawing/cat_axis.rb +43 -39
  60. data/lib/axlsx/drawing/chart.rb +65 -54
  61. data/lib/axlsx/drawing/d_lbls.rb +100 -0
  62. data/lib/axlsx/drawing/drawing.rb +20 -8
  63. data/lib/axlsx/drawing/graphic_frame.rb +2 -1
  64. data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
  65. data/lib/axlsx/drawing/num_data.rb +2 -2
  66. data/lib/axlsx/drawing/num_data_source.rb +4 -1
  67. data/lib/axlsx/drawing/pic.rb +44 -4
  68. data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
  69. data/lib/axlsx/drawing/scatter_chart.rb +2 -8
  70. data/lib/axlsx/drawing/title.rb +21 -9
  71. data/lib/axlsx/drawing/two_cell_anchor.rb +46 -9
  72. data/lib/axlsx/drawing/view_3D.rb +42 -32
  73. data/lib/axlsx/drawing/vml_drawing.rb +42 -0
  74. data/lib/axlsx/drawing/vml_shape.rb +125 -0
  75. data/lib/axlsx/package.rb +43 -16
  76. data/lib/axlsx/rels/relationship.rb +3 -3
  77. data/lib/axlsx/rels/relationships.rb +1 -11
  78. data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
  79. data/lib/axlsx/stylesheet/styles.rb +11 -2
  80. data/lib/axlsx/stylesheet/table_style.rb +3 -3
  81. data/lib/axlsx/util/constants.rb +131 -2
  82. data/lib/axlsx/util/simple_typed_list.rb +18 -22
  83. data/lib/axlsx/util/validators.rb +100 -9
  84. data/lib/axlsx/version.rb +2 -7
  85. data/lib/axlsx/workbook/defined_name.rb +174 -0
  86. data/lib/axlsx/workbook/defined_names.rb +21 -0
  87. data/lib/axlsx/workbook/workbook.rb +70 -13
  88. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +77 -0
  89. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +102 -0
  90. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +253 -0
  91. data/lib/axlsx/workbook/worksheet/cell.rb +41 -8
  92. data/lib/axlsx/workbook/worksheet/col.rb +15 -0
  93. data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
  94. data/lib/axlsx/workbook/worksheet/comment.rb +101 -0
  95. data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
  96. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
  97. data/lib/axlsx/workbook/worksheet/data_bar.rb +1 -1
  98. data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
  99. data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
  100. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +1 -1
  101. data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
  102. data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
  103. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +47 -0
  104. data/lib/axlsx/workbook/worksheet/page_setup.rb +241 -0
  105. data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
  106. data/lib/axlsx/workbook/worksheet/print_options.rb +63 -0
  107. data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
  108. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
  109. data/lib/axlsx/workbook/worksheet/row.rb +36 -20
  110. data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
  111. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +49 -0
  112. data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
  113. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +107 -0
  114. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
  115. data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
  116. data/lib/axlsx/workbook/worksheet/table.rb +10 -3
  117. data/lib/axlsx/workbook/worksheet/table_style_info.rb +68 -0
  118. data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
  119. data/lib/axlsx/workbook/worksheet/worksheet.rb +414 -254
  120. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
  121. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
  122. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +101 -0
  123. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +38 -0
  124. data/lib/axlsx.rb +38 -16
  125. data/test/content_type/tc_content_type.rb +1 -6
  126. data/test/doc_props/tc_app.rb +31 -1
  127. data/test/doc_props/tc_core.rb +3 -1
  128. data/test/drawing/tc_axis.rb +38 -3
  129. data/test/drawing/tc_bar_3D_chart.rb +12 -12
  130. data/test/drawing/tc_bar_series.rb +1 -2
  131. data/test/drawing/tc_cat_axis.rb +3 -3
  132. data/test/drawing/tc_chart.rb +29 -9
  133. data/test/drawing/tc_d_lbls.rb +47 -0
  134. data/test/drawing/tc_drawing.rb +11 -5
  135. data/test/drawing/tc_hyperlink.rb +4 -5
  136. data/test/drawing/tc_line_series.rb +7 -3
  137. data/test/drawing/tc_num_data.rb +5 -1
  138. data/test/drawing/tc_pic.rb +22 -2
  139. data/test/drawing/tc_pie_3D_chart.rb +4 -8
  140. data/test/drawing/tc_pie_series.rb +7 -2
  141. data/test/drawing/tc_scatter_chart.rb +6 -1
  142. data/test/drawing/tc_scatter_series.rb +1 -1
  143. data/test/drawing/tc_series.rb +1 -1
  144. data/test/drawing/tc_title.rb +16 -0
  145. data/test/drawing/tc_two_cell_anchor.rb +1 -2
  146. data/test/drawing/tc_view_3D.rb +18 -18
  147. data/test/drawing/tc_vml_drawing.rb +25 -0
  148. data/test/drawing/tc_vml_shape.rb +100 -0
  149. data/test/rels/tc_relationship.rb +1 -0
  150. data/test/stylesheet/tc_gradient_fill.rb +8 -0
  151. data/test/stylesheet/tc_pattern_fill.rb +7 -1
  152. data/test/stylesheet/tc_styles.rb +16 -4
  153. data/test/stylesheet/tc_table_style.rb +8 -0
  154. data/test/stylesheet/tc_table_style_element.rb +10 -1
  155. data/test/tc_helper.rb +1 -0
  156. data/test/tc_package.rb +94 -17
  157. data/test/util/tc_simple_typed_list.rb +13 -0
  158. data/test/util/tc_validators.rb +101 -8
  159. data/test/workbook/tc_defined_name.rb +41 -0
  160. data/test/workbook/tc_workbook.rb +5 -3
  161. data/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +38 -0
  162. data/test/workbook/worksheet/auto_filter/tc_filter_column.rb +76 -0
  163. data/test/workbook/worksheet/auto_filter/tc_filters.rb +50 -0
  164. data/test/workbook/worksheet/tc_cell.rb +53 -7
  165. data/test/workbook/worksheet/tc_col.rb +9 -0
  166. data/test/workbook/worksheet/tc_comment.rb +57 -0
  167. data/test/workbook/worksheet/tc_comments.rb +57 -0
  168. data/test/workbook/worksheet/tc_conditional_formatting.rb +44 -0
  169. data/test/workbook/worksheet/tc_data_bar.rb +1 -1
  170. data/test/workbook/worksheet/tc_data_validation.rb +265 -0
  171. data/test/workbook/worksheet/tc_page_set_up_pr.rb +15 -0
  172. data/test/workbook/worksheet/tc_page_setup.rb +143 -0
  173. data/test/workbook/worksheet/tc_pane.rb +94 -0
  174. data/test/workbook/worksheet/tc_print_options.rb +72 -0
  175. data/test/workbook/worksheet/tc_protected_range.rb +17 -0
  176. data/test/workbook/worksheet/tc_row.rb +32 -14
  177. data/test/workbook/worksheet/tc_selection.rb +94 -0
  178. data/test/workbook/worksheet/tc_sheet_calc_pr.rb +18 -0
  179. data/test/workbook/worksheet/tc_sheet_pr.rb +27 -0
  180. data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
  181. data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
  182. data/test/workbook/worksheet/{table/tc_table.rb → tc_table.rb} +9 -12
  183. data/test/workbook/worksheet/tc_table_style_info.rb +53 -0
  184. data/test/workbook/worksheet/tc_worksheet.rb +155 -51
  185. data/test/workbook/worksheet/tc_worksheet_hyperlink.rb +64 -0
  186. metadata +194 -81
  187. data/examples/#extractive.csv# +0 -0
  188. data/examples/#extractive.rb# +0 -45
  189. data/examples/chart_colors.rb~ +0 -0
  190. data/examples/chart_colors.xlsx +0 -0
  191. data/examples/colored_series_data.xlsx +0 -0
  192. data/examples/conditional_formatting/getting_barred.xlsx +0 -0
  193. data/examples/example.csv +0 -1000
  194. data/examples/extractive.csv +0 -1
  195. data/examples/extractive.csv~ +0 -1
  196. data/examples/extractive.rb~ +0 -3
  197. data/examples/stack.rb +0 -21
  198. data/examples/stack.rb~ +0 -27
  199. data/examples/stack.xlsx +0 -0
  200. data/examples/~$chart_colors.xlsx +0 -0
  201. data/examples/~$extractive.xlsx +0 -0
  202. data/lib/axlsx/drawing/ax_data_source.rb~ +0 -55
  203. data/lib/axlsx/drawing/data_source.rb~ +0 -51
  204. data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
  205. data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
  206. data/lib/axlsx/drawing/num_data.rb~ +0 -51
  207. data/lib/axlsx/drawing/num_data_source.rb~ +0 -54
  208. data/lib/axlsx/drawing/num_val.rb~ +0 -40
  209. data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
  210. data/lib/axlsx/drawing/ref.rb~ +0 -41
  211. data/lib/axlsx/drawing/str_data.rb~ +0 -58
  212. data/lib/axlsx/drawing/str_val.rb~ +0 -35
  213. data/lib/axlsx/util/cbf.rb +0 -333
  214. data/lib/axlsx/util/cfb.rb~ +0 -201
  215. data/lib/axlsx/util/font_tables.rb~ +0 -0
  216. data/lib/axlsx/util/ms_off_crypto.rb +0 -189
  217. data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
  218. data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
  219. data/lib/axlsx/util/parser.rb~ +0 -6
  220. data/lib/axlsx/util/storage.rb~ +0 -0
  221. data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
  222. data/lib/axlsx/workbook/worksheet/cfvo.rb~ +0 -0
  223. data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
  224. data/lib/axlsx/workbook/worksheet/color_scale.rb~ +0 -46
  225. data/lib/axlsx/workbook/worksheet/data_bar.rb~ +0 -0
  226. data/lib/axlsx/workbook/worksheet/icon_set.rb~ +0 -95
  227. data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
  228. data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
  229. data/lib/schema/dc.xsd~ +0 -118
  230. data/lib/schema/dcterms.xsd~ +0 -331
  231. data/lib/schema/opc-coreProperties.xsd~ +0 -50
  232. data/test/drawing/tc_data_source.rb~ +0 -30
  233. data/test/drawing/tc_num_data.rb~ +0 -35
  234. data/test/drawing/tc_num_val.rb~ +0 -29
  235. data/test/drawing/tc_str_data.rb~ +0 -30
  236. data/test/drawing/tc_str_val.rb~ +0 -26
  237. data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
  238. data/test/workbook/worksheet/tc_cfvo.rb~ +0 -20
  239. data/test/workbook/worksheet/tc_col.rb~ +0 -10
  240. data/test/workbook/worksheet/tc_color_scale.rb~ +0 -0
  241. data/test/workbook/worksheet/tc_data_bar.rb~ +0 -0
  242. data/test/workbook/worksheet/tc_icon_set.rb~ +0 -0
@@ -1,189 +0,0 @@
1
- # encoding: UTF-8
2
- require 'digest'
3
- require 'base64'
4
- require 'openssl'
5
-
6
- module Axlsx
7
-
8
- # The MsOffCrypto class implements ECMA-367 encryption based on the MS-OFF-CRYPTO specification
9
- class MsOffCrypto
10
-
11
- # Creates a new MsOffCrypto Object
12
- # @param [String] file_name the location of the file you want to encrypt
13
- # @param [String] pwd the password to use when encrypting the file
14
- def initialize(file_name, pwd)
15
- self.password = pwd
16
- self.file_name = file_name
17
- end
18
-
19
- # Generates a new CBF file based on this instance of ms-off-crypto and overwrites the unencrypted file.
20
- def save
21
- cfb = Cbf.new(self)
22
- cfb.save
23
- end
24
-
25
- # returns the raw password used in encryption
26
- # @return [String]
27
- attr_reader :password
28
-
29
- # sets the password to be used for encryption
30
- # @param [String] v the password, @default 'password'
31
- # @return [String]
32
- def password=(v)
33
- @password = v || 'password'
34
- end
35
-
36
- # retruns the file name of the archive to be encrypted
37
- # @return [String]
38
- attr_reader :file_name
39
-
40
- # sets the filename
41
- # @return [String]
42
- def file_name=(v)
43
- #TODO verfify that the file specified exists and is an unencrypted xlsx archive
44
- @file_name = v
45
- end
46
-
47
-
48
- # encrypts and returns the package specified by the file name
49
- # @return [String]
50
- def encrypted_package
51
- @encrypted_package ||= encrypt_package(file_name)
52
- end
53
-
54
- # returns the encryption info for this instance of ms-off-crypto
55
- # @return [String]
56
- def encryption_info
57
- @encryption_info ||= create_encryption_info
58
- end
59
-
60
- # returns a random salt
61
- # @return [String]
62
- def salt
63
- @salt ||= Digest::SHA1.digest(rand(16**16).to_s)
64
- end
65
-
66
- # returns a random verifier
67
- # @return [String]
68
- def verifier
69
- @verifier ||= rand(16**16).to_s
70
- end
71
-
72
- # returns the verifier encrytped
73
- # @return [String]
74
- def encrypted_verifier
75
- @encrypted_verifier ||= encrypt(verifier)
76
- end
77
-
78
- # returns the verifier hash encrypted
79
- # @return [String]
80
- def encrypted_verifier_hash
81
- @encrypted_verifier_hash ||= encrypt(verifier_hash)
82
- end
83
-
84
- # returns a verifier hash
85
- # @return [String]
86
- def verifier_hash
87
- @verifier_hash ||= create_verifier_hash
88
- end
89
-
90
- # returns an encryption key
91
- # @return [String]
92
- def key
93
- @key ||= create_key
94
- end
95
-
96
- # size of unencrypted package? concated with encrypted package
97
- def encrypt_package(file_name)
98
- package = File.open(file_name, 'r')
99
- crypt_pack = encrypt(package.read)
100
- [crypt_pack.size].pack('q') + crypt_pack
101
- end
102
-
103
- # Generates an encryption info structure
104
- # @return [String]
105
- def create_encryption_info
106
- header = [3, 0, 2, 0] # version
107
- # Header flags copy
108
- header.concat [0x24, 0, 0, 0] #flags -- VERY UNSURE ABOUT THIS STILL
109
- # header.concat [0, 0, 0, 0] #unused
110
- header.concat [0xA4, 0, 0, 0] #length
111
- # Header
112
- header.concat [0x24, 0, 0, 0] #flags again
113
- # header.concat [0, 0, 0, 0] #unused again,
114
- header.concat [0x0E, 0x66, 0, 0] #alg id
115
- header.concat [0x04, 0x80, 0, 0] #alg hash id
116
- header.concat [key.size, 0, 0, 0] #key size
117
- header.concat [0x18, 0, 0, 0] #provider type
118
- # header.concat [0, 0, 0, 0] #reserved 1
119
- # header.concat [0, 0, 0, 0] #reserved 2
120
- header.concat [0xA0, 0xC7, 0xDC, 0x2, 0, 0, 0, 0]
121
- header.concat "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)".bytes.to_a.pack('s*').bytes.to_a
122
- header.concat [0, 0] #null terminator
123
-
124
- #Salt Size
125
- header.concat [salt.bytes.to_a.size].pack('l').bytes.to_a
126
- #Salt
127
- header.concat salt.bytes.to_a.pack('c*').bytes.to_a
128
- # encryption verifier
129
- header.concat encrypted_verifier.bytes.to_a.pack('c*').bytes.to_a
130
-
131
- # verifier hash size -- MUST BE 32 bytes
132
- header.concat [verifier_hash.bytes.to_a.size].pack('l').bytes.to_a
133
-
134
- #encryption verifier hash
135
- header.concat encrypted_verifier_hash.bytes.to_a.pack('c*').bytes.to_a
136
-
137
- header.flatten!
138
- header.pack('c*')
139
- end
140
-
141
- # 2.3.3
142
- def create_verifier_hash
143
- vh = Digest::SHA1.digest(verifier)
144
- vh << Array.new(32 - vh.size, 0).join('')
145
- end
146
-
147
- # 2.3.4.7 ECMA-376 Document Encryption Key Generation (Standard Encryption)
148
- def create_key
149
- sha = Digest::SHA1.new() << (salt + @password)
150
- (0..49999).each { |i| sha.update(i.to_s+sha.to_s) }
151
- key = sha.update(sha.to_s+'0').digest
152
- a = key.bytes.each_with_index.map { |item, i| 0x36 ^ item }
153
- x1 = Digest::SHA1.digest((a.concat Array.new(64 - key.size, 0x36)).to_s)
154
- a = key.bytes.each_with_index.map { |item, i| 0x5C ^ item }
155
- x2 = Digest::SHA1.digest( (a.concat Array.new(64 - key.size, 0x5C) ).to_s)
156
- x3 = x1 + x2
157
- x3.bytes.to_a[(0..31)].pack('c*')
158
- end
159
-
160
- # ensures that the a hashed decryption of the encryption verifier matches the decrypted verifier hash.
161
- # @return [Boolean]
162
- def verify_password
163
- v = Digest::SHA1.digest decrypt(@encrypted_verifier)
164
- vh = decrypt(@encrypted_verifier_hash)
165
- vh[0..15] == v[0..15]
166
- end
167
-
168
- # encrypts the data proved
169
- # @param [String] data
170
- # @return [String] the encrypted data
171
- def encrypt(data)
172
- aes = OpenSSL::Cipher.new("AES-128-ECB")
173
- aes.encrypt
174
- aes.key = key
175
- aes.update(data) << aes.final
176
- end
177
-
178
- # dencrypts the data proved
179
- # @param [String] data
180
- # @return [String] the dencrypted data
181
- def decrypt(data)
182
- aes = OpenSSL::Cipher.new("AES-128-ECB")
183
- aes.decrypt
184
- aes.key = key
185
- aes.update(data) << aes.final
186
- end
187
-
188
- end
189
- end
@@ -1,3 +0,0 @@
1
- module Axlsx
2
- class MsOffcrypto
3
- end
File without changes
@@ -1,6 +0,0 @@
1
- module Axlsx
2
- # THe Parser class unzips an xlsx spread sheet and populates a new axlsx package from it.
3
- class Parser
4
-
5
- end
6
- end
File without changes
@@ -1,69 +0,0 @@
1
- # encoding: UTF--8
2
- module Axlsx
3
-
4
- # The Shared String Table class is responsible for managing and serializing common strings in a workbook.
5
- # While the ECMA-376 spec allows for both inline and shared strings it seems that at least some applications like Numbers (Mac)
6
- # and Google Docs require that the shared string table is populated in order to interoperate properly.
7
- # As a developer, you should never need to directly work against this class. Simply set 'use_shared_strings'
8
- # on the package or workbook to generate a package that uses the shared strings table instead of inline strings.
9
- # @note Serialization performance is affected by using this serialization method so if you do not need interoperability
10
- # it is recomended that you use the default inline string method of serialization.
11
- class SharedStringsTable
12
-
13
- # The total number of strings in the workbook including duplicates
14
- # Empty cells are treated as blank strings
15
- # @return [Integer]
16
- attr_reader :count
17
-
18
- # The total number of unique strings in the workbook.
19
- # @return [Integer]
20
- def unique_count
21
- @unique_cells.size
22
- end
23
-
24
- # An array of unique cells. Multiple attributes of the cell are used in comparison
25
- # each of these unique cells is parsed into the shared string table.
26
- # @see Cell#sharable
27
- attr_reader :unique_cells
28
-
29
- # Creates a new Shared Strings Table agains an array of cells
30
- # @param [Array] cells This is an array of all of the cells in the workbook
31
- def initialize(cells)
32
- cells = cells.reject { |c| c.type != :string }
33
- @count = cells.size
34
- @unique_cells = []
35
- resolve cells
36
- end
37
-
38
- # Interate over all of the cells in the array.
39
- # if our unique cells array does not contain a sharable cell,
40
- # add the cell to our unique cells array and set the ssti attribute on the index of this cell in the shared strings table
41
- # if a sharable cell already exists in our unique_cells array, set the ssti attribute of the cell and move on.
42
- # @return [Array] unique cells
43
- def resolve(cells)
44
- cells.each do |cell|
45
- index = @unique_cells.index { |item| item.sharable(cell) }
46
- if index == nil
47
- cell.ssti = @unique_cells.size
48
- @unique_cells << cell
49
- else
50
- cell.ssti = index
51
- end
52
- end
53
- end
54
-
55
- # Generate the xml document for the Shared Strings Table
56
- # @return [String]
57
- def to_xml
58
- builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
59
- xml.sst(:xmlns => Axlsx::XML_NS, :count => count, :uniqueCount => unique_count) {
60
- @unique_cells.each do |cell|
61
- xml.si { xml.t cell.value.to_s }
62
- end
63
- }
64
- end
65
- builder.to_xml(:save_with => 0)
66
- end
67
- end
68
-
69
- end
File without changes
File without changes
@@ -1,46 +0,0 @@
1
- module Axlsx
2
- # Conditional Format Rule color scale object
3
- # Describes a gradated color scale in this conditional formatting rule.
4
-
5
- # @note The recommended way to manage these rules is via Worksheet#add_conditional_formatting
6
- # @see Worksheet#add_conditional_formatting
7
- # @see ConditionalFormattingRule#initialize
8
- class ColorScale
9
-
10
- # A simple typed list of cfvos
11
- # @return [SimpleTypedList]
12
- # @see cfvo
13
- attr_reader :cfvos
14
-
15
- # A simple types list of colors
16
- # @return [SimpleTypedList]
17
- # @see Color
18
- attr_reader :colors
19
-
20
- def initializer
21
- initialize_cfvos
22
- initialize_colors
23
- yield self if block_given?
24
- end
25
-
26
- def add
27
- @cfvos << Cfvo.new(:type => :min, :val => 0)
28
- @colors << Color.new :rgb => "FF000000"
29
- {:cfvo => @cfvos.last, :color => @colors.last}
30
- end
31
-
32
- protected
33
-
34
- def initialize_cfvos
35
- @cfvos = SimpleTypedList.new Cfvo
36
- @cfvos.concat [Cfvo.new(:type => :min, :val => 0), Cfvo.new(:type => :max, :val => 0)]
37
- @cfvos.lock
38
- end
39
-
40
- def initialize_colors
41
- @colors = SimpleTypedList.new Color
42
- @colors.concat [Color.new(:rgb => "FFFF0000", Color.new(:rgb => "FF0000FF")]
43
- @colors.lock
44
- end
45
-
46
- end
File without changes
@@ -1,95 +0,0 @@
1
- module Axlsx
2
- # Conditional Format Rule data bar object
3
- # Describes a data bar conditional formatting rule.
4
-
5
- # @note The recommended way to manage these rules is via Worksheet#add_conditional_formatting
6
- # @see Worksheet#add_conditional_formatting
7
- # @see ConditionalFormattingRule#initialize
8
- class DataBar
9
- CHILD_ELEMENTS = [:value_objects]
10
-
11
- # minLength attribute
12
- # The minimum length of the data bar, as a percentage of the cell width.
13
- # The default value is 10
14
- # @return [Integer]
15
- attr_reader :minLength
16
-
17
- # maxLength attribute
18
- # The maximum length of the data bar, as a percentage of the cell width.
19
- # The default value is 90
20
- # @return [Integer]
21
- attr_reader :maxLength
22
-
23
- # maxLength attribute
24
- # Indicates whether to show the values of the cells on which this data bar is applied.
25
- # The default value is true
26
- # @return [Boolean]
27
- attr_reader :showValue
28
-
29
- # A simple typed list of cfvos
30
- # @return [SimpleTypedList]
31
- # @see Cfvo
32
- attr_reader :value_objects
33
-
34
- # color
35
- # the color object used in the data bar formatting
36
- # @return [Color]
37
- def color
38
- @color ||= Color.new :rgb => "FF0000FF"
39
- end
40
-
41
- # Creates a new data bar conditional formatting object
42
- # @option options [Integer] minLength
43
- # @option options [Integer] maxLength
44
- # @option options [Boolean] showValue
45
- # @option options [String] color - the rbg value used to color the bars
46
- def initialize(options = {})
47
- @minLength = 10
48
- @maxLength = 90
49
- @showValue = true
50
- initialize_value_objects
51
- options.each do |o|
52
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
53
- end
54
- yield self if block_given?
55
- end
56
-
57
- # @see minLength
58
- def minLength=(v); Axlsx.validate_unsigned_int(v); @minLength = v end
59
- # @see maxLength
60
- def maxLength=(v); Axlsx.validate_unsigned_int(v); @maxLength = v end
61
-
62
- # @see showValue
63
- def showValue=(v); Axlsx.validate_boolean(v); @showValue = v end
64
-
65
- # Sets the color for the data bars.
66
- # @param [Color|String] The color object, or rgb string value to apply
67
- def color=(v)
68
- @color = v if v.is_a? Color
69
- self.color.rgb = v if v.is_a? String
70
- @color
71
- end
72
-
73
- # Serialize this object to an xml string
74
- # @param [String] str
75
- # @return [String]
76
- def to_xml_string(str="")
77
- str << '<dataBar '
78
- str << instance_values.map { |key, value| '' << key << '="' << value.to_s << '"' unless CHILD_ELEMENTS.include?(key.to_sym) }.join(' ')
79
- str << '>'
80
- @value_objects.each { |cfvo| cfvo.to_xml_string(str) }
81
- self.color.to_xml_string(str)
82
- str << '</dataBar>'
83
- end
84
-
85
- private
86
-
87
- # Initalize the simple typed list of value objects
88
- # I am keeping this private for now as I am not sure what impact changes to the required two cfvo objects will do.
89
- def initialize_value_objects
90
- @value_objects = SimpleTypedList.new Cfvo
91
- @value_objects.concat [Cfvo.new(:type => :min, :val => 0), Cfvo.new(:type => :max, :val => 0)]
92
- @value_objects.lock
93
- end
94
- end
95
- end
@@ -1,97 +0,0 @@
1
- # encoding: UTF-8
2
- module Axlsx
3
- # Table
4
- # @note Worksheet#add_table is the recommended way to create charts for your worksheets.
5
- # @see README for examples
6
- class Table
7
-
8
-
9
- # The reference to the table data
10
- # @return [String]
11
- attr_reader :ref
12
-
13
- # The name of the table.
14
- # @return [String]
15
- attr_reader :name
16
-
17
- # The style for the table.
18
- # @return [TableStyle]
19
- attr_reader :style
20
-
21
- # Creates a new Table object
22
- # @param [String] ref The reference to the table data.
23
- # @param [Sheet] ref The sheet containing the table data.
24
- # @option options [Cell, String] name
25
- # @option options [TableStyle] style
26
- def initialize(ref, sheet, options={})
27
- @ref = ref
28
- @sheet = sheet
29
- @style = nil
30
- @sheet.workbook.tables << self
31
- @name = "Table#{index+1}"
32
- options.each do |o|
33
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
34
- end
35
- yield self if block_given?
36
- end
37
-
38
- # The index of this chart in the workbooks charts collection
39
- # @return [Integer]
40
- def index
41
- @sheet.workbook.tables.index(self)
42
- end
43
-
44
- # The part name for this table
45
- # @return [String]
46
- def pn
47
- "#{TABLE_PN % (index+1)}"
48
- end
49
-
50
- # The relation reference id for this table
51
- # @return [String]
52
- def rId
53
- "rId#{index+1}"
54
- end
55
-
56
- # The name of the Table.
57
- # @param [String, Cell] v
58
- # @return [Title]
59
- def name=(v)
60
- DataTypeValidator.validate "#{self.class}.name", [String], v
61
- if v.is_a?(String)
62
- @name = v
63
- end
64
- end
65
-
66
-
67
- # The style for the table.
68
- # TODO
69
- # def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, lambda { |arg| arg >= 1 && arg <= 48 }; @style = v; end
70
-
71
- # Table Serialization
72
- # serializes the table
73
- def to_xml
74
- builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
75
- xml.table(:xmlns => XML_NS, :id => index+1, :name => @name, :displayName => @name.gsub(/\s/,'_'), :ref => @ref, :totalsRowShown => 0) {
76
- xml.autoFilter :ref=>@ref
77
- xml.tableColumns(:count => header_cells.length) {
78
- header_cells.each_with_index do |cell,index|
79
- xml.tableColumn :id => index+1, :name => cell.value
80
- end
81
- }
82
- xml.tableStyleInfo :showFirstColumn=>"0", :showLastColumn=>"0", :showRowStripes=>"1", :showColumnStripes=>"0", :name=>"TableStyleMedium9"
83
- #TODO implement tableStyleInfo
84
- }
85
- end
86
- builder.to_xml(:save_with => 0)
87
- end
88
-
89
- private
90
-
91
- # get the header cells (hackish)
92
- def header_cells
93
- header = @ref.gsub(/^(\w+)(\d+)\:(\w+)\d+$/, '\1\2:\3\2')
94
- @sheet[header]
95
- end
96
- end
97
- end
data/lib/schema/dc.xsd~ DELETED
@@ -1,118 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
3
- xmlns="http://purl.org/dc/elements/1.1/"
4
- targetNamespace="http://purl.org/dc/elements/1.1/"
5
- elementFormDefault="qualified"
6
- attributeFormDefault="unqualified">
7
-
8
- <xs:annotation>
9
- <xs:documentation xml:lang="en">
10
- DCMES 1.1 XML Schema
11
- XML Schema for http://purl.org/dc/elements/1.1/ namespace
12
-
13
- Created 2003-04-02
14
-
15
- Created by
16
-
17
- Tim Cole (t-cole3@uiuc.edu)
18
- Tom Habing (thabing@uiuc.edu)
19
- Jane Hunter (jane@dstc.edu.au)
20
- Pete Johnston (p.johnston@ukoln.ac.uk),
21
- Carl Lagoze (lagoze@cs.cornell.edu)
22
-
23
- This schema declares XML elements for the 15 DC elements from the
24
- http://purl.org/dc/elements/1.1/ namespace.
25
-
26
- It defines a complexType SimpleLiteral which permits mixed content
27
- and makes the xml:lang attribute available. It disallows child elements by
28
- use of minOcccurs/maxOccurs.
29
-
30
- However, this complexType does permit the derivation of other complexTypes
31
- which would permit child elements.
32
-
33
- All elements are declared as substitutable for the abstract element any,
34
- which means that the default type for all elements is dc:SimpleLiteral.
35
-
36
- </xs:documentation>
37
-
38
- </xs:annotation>
39
-
40
-
41
- <xs:import namespace="http://www.w3.org/XML/1998/namespace"
42
- schemaLocation="http://www.w3.org/2001/03/xml.xsd">
43
- </xs:import>
44
-
45
- <xs:complexType name="SimpleLiteral">
46
- <xs:annotation>
47
- <xs:documentation xml:lang="en">
48
- This is the default type for all of the DC elements.
49
- It permits text content only with optional
50
- xml:lang attribute.
51
- Text is allowed because mixed="true", but sub-elements
52
- are disallowed because minOccurs="0" and maxOccurs="0"
53
- are on the xs:any tag.
54
-
55
- This complexType allows for restriction or extension permitting
56
- child elements.
57
- </xs:documentation>
58
- </xs:annotation>
59
-
60
- <xs:complexContent mixed="true">
61
- <xs:restriction base="xs:anyType">
62
- <xs:sequence>
63
- <xs:any processContents="lax" minOccurs="0" maxOccurs="0"/>
64
- </xs:sequence>
65
- <xs:attribute ref="xml:lang" use="optional"/>
66
- </xs:restriction>
67
- </xs:complexContent>
68
- </xs:complexType>
69
-
70
- <xs:element name="any" type="SimpleLiteral" abstract="true"/>
71
-
72
- <xs:element name="title" substitutionGroup="any"/>
73
- <xs:element name="creator" substitutionGroup="any"/>
74
- <xs:element name="subject" substitutionGroup="any"/>
75
- <xs:element name="description" substitutionGroup="any"/>
76
- <xs:element name="publisher" substitutionGroup="any"/>
77
- <xs:element name="contributor" substitutionGroup="any"/>
78
- <xs:element name="date" substitutionGroup="any"/>
79
- <xs:element name="type" substitutionGroup="any"/>
80
- <xs:element name="format" substitutionGroup="any"/>
81
- <xs:element name="identifier" substitutionGroup="any"/>
82
- <xs:element name="source" substitutionGroup="any"/>
83
- <xs:element name="language" substitutionGroup="any"/>
84
- <xs:element name="relation" substitutionGroup="any"/>
85
- <xs:element name="coverage" substitutionGroup="any"/>
86
- <xs:element name="rights" substitutionGroup="any"/>
87
-
88
- <xs:group name="elementsGroup">
89
- <xs:annotation>
90
- <xs:documentation xml:lang="en">
91
- This group is included as a convenience for schema authors
92
- who need to refer to all the elements in the
93
- http://purl.org/dc/elements/1.1/ namespace.
94
- </xs:documentation>
95
- </xs:annotation>
96
-
97
- <xs:sequence>
98
- <xs:choice minOccurs="0" maxOccurs="unbounded">
99
- <xs:element ref="any"/>
100
- </xs:choice>
101
- </xs:sequence>
102
- </xs:group>
103
-
104
- <xs:complexType name="elementContainer">
105
- <xs:annotation>
106
- <xs:documentation xml:lang="en">
107
- This complexType is included as a convenience for schema authors who need to define a root
108
- or container element for all of the DC elements.
109
- </xs:documentation>
110
- </xs:annotation>
111
-
112
- <xs:choice>
113
- <xs:group ref="elementsGroup"/>
114
- </xs:choice>
115
- </xs:complexType>
116
-
117
-
118
- </xs:schema>