ironcalc 0.7.1.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 +7 -0
- data/CHANGELOG.md +6 -0
- data/Cargo.lock +1239 -0
- data/Cargo.toml +9 -0
- data/LICENSE-Apache-2.0.md +191 -0
- data/LICENSE-MIT.md +9 -0
- data/README.md +124 -0
- data/ext/ironcalc/Cargo.toml +18 -0
- data/ext/ironcalc/extconf.rb +4 -0
- data/ext/ironcalc/src/error.rs +17 -0
- data/ext/ironcalc/src/lib.rs +270 -0
- data/ext/ironcalc/src/model.rs +330 -0
- data/ext/ironcalc/src/user_model.rs +365 -0
- data/lib/ironcalc/model.rb +81 -0
- data/lib/ironcalc/native_methods.rb +501 -0
- data/lib/ironcalc/version.rb +3 -0
- data/lib/ironcalc.rb +11 -0
- metadata +74 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
# Ruby-side conveniences layered on top of the native classes. Styles cross the
|
|
4
|
+
# native boundary as JSON; here we expose them as plain Ruby hashes, mirroring
|
|
5
|
+
# the Node binding's serde-based approach.
|
|
6
|
+
module IronCalc
|
|
7
|
+
class Model
|
|
8
|
+
# Returns the cell style as a Hash with string keys (snake_case, matching the
|
|
9
|
+
# engine's serde field names), e.g.
|
|
10
|
+
# { "num_fmt" => "general", "font" => { "b" => false, ... }, ... }
|
|
11
|
+
#
|
|
12
|
+
# @param sheet [Integer] 0-based sheet index
|
|
13
|
+
# @param row [Integer] 1-based row
|
|
14
|
+
# @param column [Integer] 1-based column
|
|
15
|
+
# @return [Hash]
|
|
16
|
+
# @raise [IronCalc::Error]
|
|
17
|
+
def get_cell_style(sheet, row, column)
|
|
18
|
+
JSON.parse(get_cell_style_json(sheet, row, column))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Sets the cell style from a Hash (snake_case keys) or a JSON string.
|
|
22
|
+
#
|
|
23
|
+
# @param sheet [Integer] 0-based sheet index
|
|
24
|
+
# @param row [Integer] 1-based row
|
|
25
|
+
# @param column [Integer] 1-based column
|
|
26
|
+
# @param style [Hash, String] the full style as a Hash or JSON string
|
|
27
|
+
# @return [void]
|
|
28
|
+
# @raise [IronCalc::Error]
|
|
29
|
+
def set_cell_style(sheet, row, column, style)
|
|
30
|
+
json = style.is_a?(String) ? style : JSON.generate(style)
|
|
31
|
+
set_cell_style_json(sheet, row, column, json)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class UserModel
|
|
36
|
+
# Returns the cell style as a Hash with string keys, like {Model#get_cell_style}.
|
|
37
|
+
#
|
|
38
|
+
# @param sheet [Integer] 0-based sheet index
|
|
39
|
+
# @param row [Integer] 1-based row
|
|
40
|
+
# @param column [Integer] 1-based column
|
|
41
|
+
# @return [Hash]
|
|
42
|
+
# @raise [IronCalc::Error]
|
|
43
|
+
def get_cell_style(sheet, row, column)
|
|
44
|
+
JSON.parse(get_cell_style_json(sheet, row, column))
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Sets the cell style from a Hash (or JSON string). The user model has no
|
|
48
|
+
# whole-style setter; styling is per-property via the engine's
|
|
49
|
+
# {#update_range_style} (mirroring the WASM binding). This convenience
|
|
50
|
+
# flattens the Hash and applies each leaf with {UserModel#update_range_style}.
|
|
51
|
+
#
|
|
52
|
+
# @param sheet [Integer] 0-based sheet index
|
|
53
|
+
# @param row [Integer] 1-based row
|
|
54
|
+
# @param column [Integer] 1-based column
|
|
55
|
+
# @param style [Hash, String] the style as a Hash or JSON string
|
|
56
|
+
# @return [void]
|
|
57
|
+
# @raise [IronCalc::Error]
|
|
58
|
+
def set_cell_style(sheet, row, column, style)
|
|
59
|
+
desired = style.is_a?(String) ? JSON.parse(style) : style
|
|
60
|
+
flatten_style(desired).each do |path, value|
|
|
61
|
+
update_range_style(sheet, row, column, path, value.to_s)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
# Flattens a nested style Hash to engine style paths, e.g.
|
|
68
|
+
# { "font" => { "b" => true } } => { "font.b" => true }
|
|
69
|
+
# @api private
|
|
70
|
+
def flatten_style(hash, prefix = nil)
|
|
71
|
+
hash.each_with_object({}) do |(key, value), out|
|
|
72
|
+
path = prefix ? "#{prefix}.#{key}" : key.to_s
|
|
73
|
+
if value.is_a?(Hash)
|
|
74
|
+
out.merge!(flatten_style(value, path))
|
|
75
|
+
else
|
|
76
|
+
out[path] = value
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
# Documentation-only stubs for the methods implemented in the native extension
|
|
2
|
+
# (ext/ironcalc, via magnus). YARD cannot see Rust source, so the public native
|
|
3
|
+
# API is described here with `@!method` directives. This file is NOT required at
|
|
4
|
+
# runtime — the real methods are defined by the compiled extension. Keep these
|
|
5
|
+
# stubs in sync with the Rust sources in ext/ironcalc/src (and `rake parity`).
|
|
6
|
+
#
|
|
7
|
+
# Coordinate convention everywhere: +sheet+ is a 0-based index; +row+ and
|
|
8
|
+
# +column+ are 1-based.
|
|
9
|
+
|
|
10
|
+
module IronCalc
|
|
11
|
+
# @!method create(name, locale, tz, language_id)
|
|
12
|
+
# @!scope class
|
|
13
|
+
# Creates an empty workbook using the raw {Model} API.
|
|
14
|
+
# @param name [String] workbook name
|
|
15
|
+
# @param locale [String] e.g. "en"
|
|
16
|
+
# @param tz [String] IANA timezone, e.g. "UTC"
|
|
17
|
+
# @param language_id [String] e.g. "en"
|
|
18
|
+
# @return [IronCalc::Model]
|
|
19
|
+
# @raise [IronCalc::Error]
|
|
20
|
+
|
|
21
|
+
# @!method load_from_xlsx(file_path, locale, tz, language_id)
|
|
22
|
+
# @!scope class
|
|
23
|
+
# Loads a workbook from an xlsx file into the raw {Model} API.
|
|
24
|
+
# @param file_path [String]
|
|
25
|
+
# @param locale [String]
|
|
26
|
+
# @param tz [String]
|
|
27
|
+
# @param language_id [String]
|
|
28
|
+
# @return [IronCalc::Model]
|
|
29
|
+
# @raise [IronCalc::Error]
|
|
30
|
+
|
|
31
|
+
# @!method load_from_icalc(file_name, language_id)
|
|
32
|
+
# @!scope class
|
|
33
|
+
# Loads a workbook from the internal binary icalc format.
|
|
34
|
+
# @param file_name [String]
|
|
35
|
+
# @param language_id [String]
|
|
36
|
+
# @return [IronCalc::Model]
|
|
37
|
+
# @raise [IronCalc::Error]
|
|
38
|
+
|
|
39
|
+
# @!method load_from_bytes(bytes, language_id)
|
|
40
|
+
# @!scope class
|
|
41
|
+
# Loads a workbook from icalc bytes (as produced by {Model#to_bytes}).
|
|
42
|
+
# @param bytes [String] binary icalc bytes
|
|
43
|
+
# @param language_id [String]
|
|
44
|
+
# @return [IronCalc::Model]
|
|
45
|
+
# @raise [IronCalc::Error]
|
|
46
|
+
|
|
47
|
+
# @!method create_user_model(name, locale, tz, language_id)
|
|
48
|
+
# @!scope class
|
|
49
|
+
# Creates an empty workbook using the recommended {UserModel} API.
|
|
50
|
+
# @param name [String]
|
|
51
|
+
# @param locale [String]
|
|
52
|
+
# @param tz [String]
|
|
53
|
+
# @param language_id [String]
|
|
54
|
+
# @return [IronCalc::UserModel]
|
|
55
|
+
# @raise [IronCalc::Error]
|
|
56
|
+
|
|
57
|
+
# @!method create_user_model_from_xlsx(file_path, locale, tz, language_id)
|
|
58
|
+
# @!scope class
|
|
59
|
+
# Loads an xlsx file into the {UserModel} API.
|
|
60
|
+
# @param file_path [String]
|
|
61
|
+
# @param locale [String]
|
|
62
|
+
# @param tz [String]
|
|
63
|
+
# @param language_id [String]
|
|
64
|
+
# @return [IronCalc::UserModel]
|
|
65
|
+
# @raise [IronCalc::Error]
|
|
66
|
+
|
|
67
|
+
# @!method create_user_model_from_icalc(file_name, language_id)
|
|
68
|
+
# @!scope class
|
|
69
|
+
# Loads an icalc file into the {UserModel} API.
|
|
70
|
+
# @param file_name [String]
|
|
71
|
+
# @param language_id [String]
|
|
72
|
+
# @return [IronCalc::UserModel]
|
|
73
|
+
# @raise [IronCalc::Error]
|
|
74
|
+
|
|
75
|
+
# @!method create_user_model_from_bytes(bytes, language_id)
|
|
76
|
+
# @!scope class
|
|
77
|
+
# Loads icalc bytes into the {UserModel} API.
|
|
78
|
+
# @param bytes [String] binary icalc bytes
|
|
79
|
+
# @param language_id [String]
|
|
80
|
+
# @return [IronCalc::UserModel]
|
|
81
|
+
# @raise [IronCalc::Error]
|
|
82
|
+
|
|
83
|
+
# The raw IronCalc API. You must call {#evaluate} yourself after changing
|
|
84
|
+
# inputs; misuse can leave the workbook in an inconsistent state. This mirrors
|
|
85
|
+
# the Python binding's `Model`. For most uses prefer {UserModel}, which
|
|
86
|
+
# auto-evaluates.
|
|
87
|
+
class Model
|
|
88
|
+
# @!method save_to_xlsx(file)
|
|
89
|
+
# Saves the workbook to an xlsx file. Fails if the file already exists.
|
|
90
|
+
# @param file [String]
|
|
91
|
+
# @return [void]
|
|
92
|
+
# @raise [IronCalc::Error]
|
|
93
|
+
|
|
94
|
+
# @!method save_to_icalc(file)
|
|
95
|
+
# Saves the workbook to the internal binary icalc format.
|
|
96
|
+
# @param file [String]
|
|
97
|
+
# @return [void]
|
|
98
|
+
# @raise [IronCalc::Error]
|
|
99
|
+
|
|
100
|
+
# @!method to_bytes
|
|
101
|
+
# Serializes the workbook to icalc bytes (load with {IronCalc.load_from_bytes}).
|
|
102
|
+
# @return [String] binary string
|
|
103
|
+
|
|
104
|
+
# @!method evaluate
|
|
105
|
+
# Recalculates the whole workbook. Call after {#set_user_input}.
|
|
106
|
+
# @return [void]
|
|
107
|
+
|
|
108
|
+
# @!method set_user_input(sheet, row, column, value)
|
|
109
|
+
# Sets a cell's raw input (a literal or a formula like "=A1+1").
|
|
110
|
+
# @param sheet [Integer]
|
|
111
|
+
# @param row [Integer]
|
|
112
|
+
# @param column [Integer]
|
|
113
|
+
# @param value [String]
|
|
114
|
+
# @return [void]
|
|
115
|
+
# @raise [IronCalc::Error]
|
|
116
|
+
|
|
117
|
+
# @!method clear_cell_contents(sheet, row, column)
|
|
118
|
+
# Clears a cell's contents (not its style).
|
|
119
|
+
# @param sheet [Integer]
|
|
120
|
+
# @param row [Integer]
|
|
121
|
+
# @param column [Integer]
|
|
122
|
+
# @return [void]
|
|
123
|
+
# @raise [IronCalc::Error]
|
|
124
|
+
|
|
125
|
+
# @!method get_cell_content(sheet, row, column)
|
|
126
|
+
# Returns the cell's content: the formula (e.g. "=A1+1") or literal text.
|
|
127
|
+
# @param sheet [Integer]
|
|
128
|
+
# @param row [Integer]
|
|
129
|
+
# @param column [Integer]
|
|
130
|
+
# @return [String]
|
|
131
|
+
# @raise [IronCalc::Error]
|
|
132
|
+
|
|
133
|
+
# @!method get_cell_type(sheet, row, column)
|
|
134
|
+
# Returns the cell type as a Symbol: +:number+, +:text+, +:logical_value+,
|
|
135
|
+
# +:error_value+, +:array+ or +:compound_data+.
|
|
136
|
+
# @param sheet [Integer]
|
|
137
|
+
# @param row [Integer]
|
|
138
|
+
# @param column [Integer]
|
|
139
|
+
# @return [Symbol]
|
|
140
|
+
# @raise [IronCalc::Error]
|
|
141
|
+
|
|
142
|
+
# @!method get_formatted_cell_value(sheet, row, column)
|
|
143
|
+
# Returns the cell's value formatted as displayed (number format applied).
|
|
144
|
+
# @param sheet [Integer]
|
|
145
|
+
# @param row [Integer]
|
|
146
|
+
# @param column [Integer]
|
|
147
|
+
# @return [String]
|
|
148
|
+
# @raise [IronCalc::Error]
|
|
149
|
+
|
|
150
|
+
# @!method get_cell_style_json(sheet, row, column)
|
|
151
|
+
# @api private
|
|
152
|
+
# JSON backing for `get_cell_style`. Prefer the Hash-returning wrapper.
|
|
153
|
+
# @return [String]
|
|
154
|
+
|
|
155
|
+
# @!method set_cell_style_json(sheet, row, column, style_json)
|
|
156
|
+
# @api private
|
|
157
|
+
# JSON backing for `set_cell_style`. Prefer the Hash-accepting wrapper.
|
|
158
|
+
# @return [void]
|
|
159
|
+
|
|
160
|
+
# @!method insert_rows(sheet, row, row_count)
|
|
161
|
+
# Inserts +row_count+ rows before +row+.
|
|
162
|
+
# @param sheet [Integer]
|
|
163
|
+
# @param row [Integer]
|
|
164
|
+
# @param row_count [Integer]
|
|
165
|
+
# @return [void]
|
|
166
|
+
# @raise [IronCalc::Error]
|
|
167
|
+
|
|
168
|
+
# @!method insert_columns(sheet, column, column_count)
|
|
169
|
+
# Inserts +column_count+ columns before +column+.
|
|
170
|
+
# @param sheet [Integer]
|
|
171
|
+
# @param column [Integer]
|
|
172
|
+
# @param column_count [Integer]
|
|
173
|
+
# @return [void]
|
|
174
|
+
# @raise [IronCalc::Error]
|
|
175
|
+
|
|
176
|
+
# @!method delete_rows(sheet, row, row_count)
|
|
177
|
+
# Deletes +row_count+ rows starting at +row+.
|
|
178
|
+
# @param sheet [Integer]
|
|
179
|
+
# @param row [Integer]
|
|
180
|
+
# @param row_count [Integer]
|
|
181
|
+
# @return [void]
|
|
182
|
+
# @raise [IronCalc::Error]
|
|
183
|
+
|
|
184
|
+
# @!method delete_columns(sheet, column, column_count)
|
|
185
|
+
# Deletes +column_count+ columns starting at +column+.
|
|
186
|
+
# @param sheet [Integer]
|
|
187
|
+
# @param column [Integer]
|
|
188
|
+
# @param column_count [Integer]
|
|
189
|
+
# @return [void]
|
|
190
|
+
# @raise [IronCalc::Error]
|
|
191
|
+
|
|
192
|
+
# @!method get_column_width(sheet, column)
|
|
193
|
+
# @param sheet [Integer]
|
|
194
|
+
# @param column [Integer]
|
|
195
|
+
# @return [Float] width in pixels
|
|
196
|
+
# @raise [IronCalc::Error]
|
|
197
|
+
|
|
198
|
+
# @!method get_row_height(sheet, row)
|
|
199
|
+
# @param sheet [Integer]
|
|
200
|
+
# @param row [Integer]
|
|
201
|
+
# @return [Float] height in pixels
|
|
202
|
+
# @raise [IronCalc::Error]
|
|
203
|
+
|
|
204
|
+
# @!method set_column_width(sheet, column, width)
|
|
205
|
+
# @param sheet [Integer]
|
|
206
|
+
# @param column [Integer]
|
|
207
|
+
# @param width [Float]
|
|
208
|
+
# @return [void]
|
|
209
|
+
# @raise [IronCalc::Error]
|
|
210
|
+
|
|
211
|
+
# @!method set_row_height(sheet, row, height)
|
|
212
|
+
# @param sheet [Integer]
|
|
213
|
+
# @param row [Integer]
|
|
214
|
+
# @param height [Float]
|
|
215
|
+
# @return [void]
|
|
216
|
+
# @raise [IronCalc::Error]
|
|
217
|
+
|
|
218
|
+
# @!method get_frozen_columns_count(sheet)
|
|
219
|
+
# @param sheet [Integer]
|
|
220
|
+
# @return [Integer]
|
|
221
|
+
# @raise [IronCalc::Error]
|
|
222
|
+
|
|
223
|
+
# @!method get_frozen_rows_count(sheet)
|
|
224
|
+
# @param sheet [Integer]
|
|
225
|
+
# @return [Integer]
|
|
226
|
+
# @raise [IronCalc::Error]
|
|
227
|
+
|
|
228
|
+
# @!method set_frozen_columns_count(sheet, count)
|
|
229
|
+
# @param sheet [Integer]
|
|
230
|
+
# @param count [Integer]
|
|
231
|
+
# @return [void]
|
|
232
|
+
# @raise [IronCalc::Error]
|
|
233
|
+
|
|
234
|
+
# @!method set_frozen_rows_count(sheet, count)
|
|
235
|
+
# @param sheet [Integer]
|
|
236
|
+
# @param count [Integer]
|
|
237
|
+
# @return [void]
|
|
238
|
+
# @raise [IronCalc::Error]
|
|
239
|
+
|
|
240
|
+
# @!method get_worksheets_properties
|
|
241
|
+
# Returns one Hash per sheet with symbol keys +:name+, +:state+,
|
|
242
|
+
# +:sheet_id+ and +:color+.
|
|
243
|
+
# @return [Array<Hash>]
|
|
244
|
+
|
|
245
|
+
# @!method set_sheet_color(sheet, color)
|
|
246
|
+
# @param sheet [Integer]
|
|
247
|
+
# @param color [String] hex color, e.g. "#FF0000"
|
|
248
|
+
# @return [void]
|
|
249
|
+
# @raise [IronCalc::Error]
|
|
250
|
+
|
|
251
|
+
# @!method add_sheet(name)
|
|
252
|
+
# Adds a new sheet with the given name.
|
|
253
|
+
# @param name [String]
|
|
254
|
+
# @return [void]
|
|
255
|
+
# @raise [IronCalc::Error]
|
|
256
|
+
|
|
257
|
+
# @!method new_sheet
|
|
258
|
+
# Adds a new sheet with an auto-generated name.
|
|
259
|
+
# @return [void]
|
|
260
|
+
|
|
261
|
+
# @!method delete_sheet(sheet)
|
|
262
|
+
# @param sheet [Integer]
|
|
263
|
+
# @return [void]
|
|
264
|
+
# @raise [IronCalc::Error]
|
|
265
|
+
|
|
266
|
+
# @!method rename_sheet(sheet, new_name)
|
|
267
|
+
# @param sheet [Integer]
|
|
268
|
+
# @param new_name [String]
|
|
269
|
+
# @return [void]
|
|
270
|
+
# @raise [IronCalc::Error]
|
|
271
|
+
|
|
272
|
+
# @!method get_sheet_dimensions(sheet)
|
|
273
|
+
# Returns +[min_row, max_row, min_column, max_column]+ over non-empty cells
|
|
274
|
+
# (an empty sheet returns +[1, 1, 1, 1]+).
|
|
275
|
+
# @param sheet [Integer]
|
|
276
|
+
# @return [Array(Integer, Integer, Integer, Integer)]
|
|
277
|
+
# @raise [IronCalc::Error]
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# The recommended, higher-level IronCalc API. Auto-evaluates after every action
|
|
281
|
+
# and records diffs for collaboration ({#flush_send_queue} /
|
|
282
|
+
# {#apply_external_diffs}). Mirrors IronCalc's WebAssembly binding and is a
|
|
283
|
+
# superset of the Python binding's `UserModel`. Styling is per-property via
|
|
284
|
+
# {UserModel#update_range_style} (the Hash convenience {UserModel#set_cell_style}
|
|
285
|
+
# is layered on top).
|
|
286
|
+
class UserModel
|
|
287
|
+
# @!method save_to_xlsx(file)
|
|
288
|
+
# Saves the workbook to an xlsx file. Fails if the file already exists.
|
|
289
|
+
# @param file [String]
|
|
290
|
+
# @return [void]
|
|
291
|
+
# @raise [IronCalc::Error]
|
|
292
|
+
|
|
293
|
+
# @!method save_to_icalc(file)
|
|
294
|
+
# Saves the workbook to the internal binary icalc format.
|
|
295
|
+
# @param file [String]
|
|
296
|
+
# @return [void]
|
|
297
|
+
# @raise [IronCalc::Error]
|
|
298
|
+
|
|
299
|
+
# @!method to_bytes
|
|
300
|
+
# Serializes the workbook to icalc bytes.
|
|
301
|
+
# @return [String] binary string
|
|
302
|
+
|
|
303
|
+
# @!method apply_external_diffs(diffs)
|
|
304
|
+
# Applies a peer's diff blob (from {#flush_send_queue}) for collaboration.
|
|
305
|
+
# @param diffs [String] binary diff blob
|
|
306
|
+
# @return [void]
|
|
307
|
+
# @raise [IronCalc::Error]
|
|
308
|
+
|
|
309
|
+
# @!method flush_send_queue
|
|
310
|
+
# Returns and clears the queued diffs to broadcast to collaborators.
|
|
311
|
+
# @return [String] binary diff blob
|
|
312
|
+
|
|
313
|
+
# @!method evaluate
|
|
314
|
+
# Forces a recalculation. Usually unnecessary — the user model
|
|
315
|
+
# auto-evaluates after each action; exposed for parity.
|
|
316
|
+
# @return [void]
|
|
317
|
+
|
|
318
|
+
# @!method undo
|
|
319
|
+
# Undoes the last change.
|
|
320
|
+
# @return [void]
|
|
321
|
+
# @raise [IronCalc::Error]
|
|
322
|
+
|
|
323
|
+
# @!method redo
|
|
324
|
+
# Redoes the last undone change.
|
|
325
|
+
# @return [void]
|
|
326
|
+
# @raise [IronCalc::Error]
|
|
327
|
+
|
|
328
|
+
# @!method can_undo
|
|
329
|
+
# @return [Boolean]
|
|
330
|
+
|
|
331
|
+
# @!method can_redo
|
|
332
|
+
# @return [Boolean]
|
|
333
|
+
|
|
334
|
+
# @!method set_user_input(sheet, row, column, value)
|
|
335
|
+
# Sets a cell's raw input (literal or formula). Triggers recalculation.
|
|
336
|
+
# @param sheet [Integer]
|
|
337
|
+
# @param row [Integer]
|
|
338
|
+
# @param column [Integer]
|
|
339
|
+
# @param value [String]
|
|
340
|
+
# @return [void]
|
|
341
|
+
# @raise [IronCalc::Error]
|
|
342
|
+
|
|
343
|
+
# @!method clear_cell_contents(sheet, row, column)
|
|
344
|
+
# Clears a cell's contents (not its style).
|
|
345
|
+
# @param sheet [Integer]
|
|
346
|
+
# @param row [Integer]
|
|
347
|
+
# @param column [Integer]
|
|
348
|
+
# @return [void]
|
|
349
|
+
# @raise [IronCalc::Error]
|
|
350
|
+
|
|
351
|
+
# @!method get_cell_content(sheet, row, column)
|
|
352
|
+
# Returns the cell's content: formula or literal text.
|
|
353
|
+
# @param sheet [Integer]
|
|
354
|
+
# @param row [Integer]
|
|
355
|
+
# @param column [Integer]
|
|
356
|
+
# @return [String]
|
|
357
|
+
# @raise [IronCalc::Error]
|
|
358
|
+
|
|
359
|
+
# @!method get_cell_type(sheet, row, column)
|
|
360
|
+
# Returns the cell type as a Symbol (see {Model#get_cell_type}).
|
|
361
|
+
# @param sheet [Integer]
|
|
362
|
+
# @param row [Integer]
|
|
363
|
+
# @param column [Integer]
|
|
364
|
+
# @return [Symbol]
|
|
365
|
+
# @raise [IronCalc::Error]
|
|
366
|
+
|
|
367
|
+
# @!method get_formatted_cell_value(sheet, row, column)
|
|
368
|
+
# Returns the cell's value formatted as displayed.
|
|
369
|
+
# @param sheet [Integer]
|
|
370
|
+
# @param row [Integer]
|
|
371
|
+
# @param column [Integer]
|
|
372
|
+
# @return [String]
|
|
373
|
+
# @raise [IronCalc::Error]
|
|
374
|
+
|
|
375
|
+
# @!method get_cell_style_json(sheet, row, column)
|
|
376
|
+
# @api private
|
|
377
|
+
# JSON backing for `get_cell_style`. Prefer the Hash-returning wrapper.
|
|
378
|
+
# @return [String]
|
|
379
|
+
|
|
380
|
+
# @!method update_range_style(sheet, row, column, style_path, value)
|
|
381
|
+
# Sets a single style property on a cell, e.g. +update_range_style(0, 1, 1,
|
|
382
|
+
# "font.b", "true")+. This is the user model's styling primitive (mirrors
|
|
383
|
+
# the WASM binding); `set_cell_style` wraps it for whole-Hash convenience.
|
|
384
|
+
# @param sheet [Integer]
|
|
385
|
+
# @param row [Integer]
|
|
386
|
+
# @param column [Integer]
|
|
387
|
+
# @param style_path [String] dotted path, e.g. "font.b", "fill.fg_color"
|
|
388
|
+
# @param value [String]
|
|
389
|
+
# @return [void]
|
|
390
|
+
# @raise [IronCalc::Error]
|
|
391
|
+
|
|
392
|
+
# @!method insert_rows(sheet, row, row_count)
|
|
393
|
+
# @param sheet [Integer]
|
|
394
|
+
# @param row [Integer]
|
|
395
|
+
# @param row_count [Integer]
|
|
396
|
+
# @return [void]
|
|
397
|
+
# @raise [IronCalc::Error]
|
|
398
|
+
|
|
399
|
+
# @!method insert_columns(sheet, column, column_count)
|
|
400
|
+
# @param sheet [Integer]
|
|
401
|
+
# @param column [Integer]
|
|
402
|
+
# @param column_count [Integer]
|
|
403
|
+
# @return [void]
|
|
404
|
+
# @raise [IronCalc::Error]
|
|
405
|
+
|
|
406
|
+
# @!method delete_rows(sheet, row, row_count)
|
|
407
|
+
# @param sheet [Integer]
|
|
408
|
+
# @param row [Integer]
|
|
409
|
+
# @param row_count [Integer]
|
|
410
|
+
# @return [void]
|
|
411
|
+
# @raise [IronCalc::Error]
|
|
412
|
+
|
|
413
|
+
# @!method delete_columns(sheet, column, column_count)
|
|
414
|
+
# @param sheet [Integer]
|
|
415
|
+
# @param column [Integer]
|
|
416
|
+
# @param column_count [Integer]
|
|
417
|
+
# @return [void]
|
|
418
|
+
# @raise [IronCalc::Error]
|
|
419
|
+
|
|
420
|
+
# @!method get_column_width(sheet, column)
|
|
421
|
+
# @param sheet [Integer]
|
|
422
|
+
# @param column [Integer]
|
|
423
|
+
# @return [Float] width in pixels
|
|
424
|
+
# @raise [IronCalc::Error]
|
|
425
|
+
|
|
426
|
+
# @!method get_row_height(sheet, row)
|
|
427
|
+
# @param sheet [Integer]
|
|
428
|
+
# @param row [Integer]
|
|
429
|
+
# @return [Float] height in pixels
|
|
430
|
+
# @raise [IronCalc::Error]
|
|
431
|
+
|
|
432
|
+
# @!method set_column_width(sheet, column, width)
|
|
433
|
+
# @param sheet [Integer]
|
|
434
|
+
# @param column [Integer]
|
|
435
|
+
# @param width [Float]
|
|
436
|
+
# @return [void]
|
|
437
|
+
# @raise [IronCalc::Error]
|
|
438
|
+
|
|
439
|
+
# @!method set_row_height(sheet, row, height)
|
|
440
|
+
# @param sheet [Integer]
|
|
441
|
+
# @param row [Integer]
|
|
442
|
+
# @param height [Float]
|
|
443
|
+
# @return [void]
|
|
444
|
+
# @raise [IronCalc::Error]
|
|
445
|
+
|
|
446
|
+
# @!method get_frozen_columns_count(sheet)
|
|
447
|
+
# @param sheet [Integer]
|
|
448
|
+
# @return [Integer]
|
|
449
|
+
# @raise [IronCalc::Error]
|
|
450
|
+
|
|
451
|
+
# @!method get_frozen_rows_count(sheet)
|
|
452
|
+
# @param sheet [Integer]
|
|
453
|
+
# @return [Integer]
|
|
454
|
+
# @raise [IronCalc::Error]
|
|
455
|
+
|
|
456
|
+
# @!method set_frozen_columns_count(sheet, count)
|
|
457
|
+
# @param sheet [Integer]
|
|
458
|
+
# @param count [Integer]
|
|
459
|
+
# @return [void]
|
|
460
|
+
# @raise [IronCalc::Error]
|
|
461
|
+
|
|
462
|
+
# @!method set_frozen_rows_count(sheet, count)
|
|
463
|
+
# @param sheet [Integer]
|
|
464
|
+
# @param count [Integer]
|
|
465
|
+
# @return [void]
|
|
466
|
+
# @raise [IronCalc::Error]
|
|
467
|
+
|
|
468
|
+
# @!method get_worksheets_properties
|
|
469
|
+
# Returns one Hash per sheet with symbol keys +:name+, +:state+,
|
|
470
|
+
# +:sheet_id+ and +:color+.
|
|
471
|
+
# @return [Array<Hash>]
|
|
472
|
+
|
|
473
|
+
# @!method set_sheet_color(sheet, color)
|
|
474
|
+
# @param sheet [Integer]
|
|
475
|
+
# @param color [String] hex color, e.g. "#FF0000"
|
|
476
|
+
# @return [void]
|
|
477
|
+
# @raise [IronCalc::Error]
|
|
478
|
+
|
|
479
|
+
# @!method new_sheet
|
|
480
|
+
# Adds a new sheet with an auto-generated name.
|
|
481
|
+
# @return [void]
|
|
482
|
+
# @raise [IronCalc::Error]
|
|
483
|
+
|
|
484
|
+
# @!method delete_sheet(sheet)
|
|
485
|
+
# @param sheet [Integer]
|
|
486
|
+
# @return [void]
|
|
487
|
+
# @raise [IronCalc::Error]
|
|
488
|
+
|
|
489
|
+
# @!method rename_sheet(sheet, new_name)
|
|
490
|
+
# @param sheet [Integer]
|
|
491
|
+
# @param new_name [String]
|
|
492
|
+
# @return [void]
|
|
493
|
+
# @raise [IronCalc::Error]
|
|
494
|
+
|
|
495
|
+
# @!method get_sheet_dimensions(sheet)
|
|
496
|
+
# Returns +[min_row, max_row, min_column, max_column]+ over non-empty cells.
|
|
497
|
+
# @param sheet [Integer]
|
|
498
|
+
# @return [Array(Integer, Integer, Integer, Integer)]
|
|
499
|
+
# @raise [IronCalc::Error]
|
|
500
|
+
end
|
|
501
|
+
end
|
data/lib/ironcalc.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require_relative "ironcalc/version"
|
|
2
|
+
|
|
3
|
+
# Load the compiled native extension. Built gems place the shared library under
|
|
4
|
+
# a Ruby-version subdirectory; a locally compiled one sits directly in lib.
|
|
5
|
+
begin
|
|
6
|
+
require "ironcalc/#{RUBY_VERSION.to_f}/ironcalc_ruby"
|
|
7
|
+
rescue LoadError
|
|
8
|
+
require "ironcalc/ironcalc_ruby"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
require_relative "ironcalc/model"
|
metadata
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ironcalc
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.7.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- jvdp
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rb_sys
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
description: 'Ruby bindings for the IronCalc spreadsheet engine. Create, read and
|
|
27
|
+
manipulate xlsx files: manage sheets, set and read cell values, and evaluate spreadsheets.'
|
|
28
|
+
email: jaap@vage-ideeen.nl
|
|
29
|
+
executables: []
|
|
30
|
+
extensions:
|
|
31
|
+
- ext/ironcalc/extconf.rb
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- CHANGELOG.md
|
|
35
|
+
- Cargo.lock
|
|
36
|
+
- Cargo.toml
|
|
37
|
+
- LICENSE-Apache-2.0.md
|
|
38
|
+
- LICENSE-MIT.md
|
|
39
|
+
- README.md
|
|
40
|
+
- ext/ironcalc/Cargo.toml
|
|
41
|
+
- ext/ironcalc/extconf.rb
|
|
42
|
+
- ext/ironcalc/src/error.rs
|
|
43
|
+
- ext/ironcalc/src/lib.rs
|
|
44
|
+
- ext/ironcalc/src/model.rs
|
|
45
|
+
- ext/ironcalc/src/user_model.rs
|
|
46
|
+
- lib/ironcalc.rb
|
|
47
|
+
- lib/ironcalc/model.rb
|
|
48
|
+
- lib/ironcalc/native_methods.rb
|
|
49
|
+
- lib/ironcalc/version.rb
|
|
50
|
+
homepage: https://github.com/ironcalc/ironcalc-ruby
|
|
51
|
+
licenses:
|
|
52
|
+
- MIT OR Apache-2.0
|
|
53
|
+
metadata:
|
|
54
|
+
homepage_uri: https://www.ironcalc.com/
|
|
55
|
+
source_code_uri: https://github.com/ironcalc/ironcalc-ruby
|
|
56
|
+
bug_tracker_uri: https://github.com/ironcalc/ironcalc-ruby/issues
|
|
57
|
+
rdoc_options: []
|
|
58
|
+
require_paths:
|
|
59
|
+
- lib
|
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: '3.0'
|
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ">="
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
requirements: []
|
|
71
|
+
rubygems_version: 4.0.10
|
|
72
|
+
specification_version: 4
|
|
73
|
+
summary: Create, edit and evaluate Excel spreadsheets
|
|
74
|
+
test_files: []
|