fast_excel 0.5.0 → 0.6.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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +5 -1
  3. data/.gitignore +3 -0
  4. data/.octocov.yml +28 -0
  5. data/CHANGELOG.md +9 -0
  6. data/Gemfile +4 -2
  7. data/Rakefile +4 -1
  8. data/examples/comment_options.rb +39 -0
  9. data/fast_excel.gemspec +3 -2
  10. data/lib/fast_excel/binding/workbook.rb +53 -6
  11. data/lib/fast_excel/binding/worksheet.rb +28 -4
  12. data/lib/fast_excel/binding.rb +116 -13
  13. data/lib/fast_excel.rb +13 -12
  14. data/libxlsxwriter/.cirrus.yml +9 -0
  15. data/libxlsxwriter/.github/workflows/cmake_actions.yml +10 -6
  16. data/libxlsxwriter/.github/workflows/code_style.yml +2 -0
  17. data/libxlsxwriter/.github/workflows/make_32_actions.yml +43 -0
  18. data/libxlsxwriter/.github/workflows/windows_build.yml +7 -6
  19. data/libxlsxwriter/.github/workflows/zig_build.yml +1 -3
  20. data/libxlsxwriter/.gitignore +9 -7
  21. data/libxlsxwriter/.indent.pro +6 -0
  22. data/libxlsxwriter/CMakeLists.txt +377 -238
  23. data/libxlsxwriter/Changes.txt +189 -0
  24. data/libxlsxwriter/LICENSE.txt +1 -1
  25. data/libxlsxwriter/Makefile +36 -4
  26. data/libxlsxwriter/Readme.md +1 -1
  27. data/libxlsxwriter/build.zig +181 -92
  28. data/libxlsxwriter/build.zig.zon +15 -4
  29. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +4 -0
  30. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  31. data/libxlsxwriter/include/xlsxwriter/chart.h +134 -1
  32. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +2 -1
  33. data/libxlsxwriter/include/xlsxwriter/comment.h +2 -1
  34. data/libxlsxwriter/include/xlsxwriter/common.h +12 -8
  35. data/libxlsxwriter/include/xlsxwriter/content_types.h +3 -1
  36. data/libxlsxwriter/include/xlsxwriter/core.h +2 -1
  37. data/libxlsxwriter/include/xlsxwriter/custom.h +2 -1
  38. data/libxlsxwriter/include/xlsxwriter/drawing.h +2 -1
  39. data/libxlsxwriter/include/xlsxwriter/format.h +34 -3
  40. data/libxlsxwriter/include/xlsxwriter/hash_table.h +2 -1
  41. data/libxlsxwriter/include/xlsxwriter/metadata.h +5 -1
  42. data/libxlsxwriter/include/xlsxwriter/packager.h +6 -1
  43. data/libxlsxwriter/include/xlsxwriter/relationships.h +3 -1
  44. data/libxlsxwriter/include/xlsxwriter/rich_value.h +51 -0
  45. data/libxlsxwriter/include/xlsxwriter/rich_value_rel.h +50 -0
  46. data/libxlsxwriter/include/xlsxwriter/rich_value_structure.h +53 -0
  47. data/libxlsxwriter/include/xlsxwriter/rich_value_types.h +49 -0
  48. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +2 -1
  49. data/libxlsxwriter/include/xlsxwriter/styles.h +2 -1
  50. data/libxlsxwriter/include/xlsxwriter/table.h +2 -1
  51. data/libxlsxwriter/include/xlsxwriter/theme.h +2 -1
  52. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +4 -4
  53. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +3 -3
  54. data/libxlsxwriter/include/xlsxwriter/utility.h +58 -7
  55. data/libxlsxwriter/include/xlsxwriter/vml.h +2 -1
  56. data/libxlsxwriter/include/xlsxwriter/workbook.h +59 -2
  57. data/libxlsxwriter/include/xlsxwriter/worksheet.h +159 -13
  58. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +11 -10
  59. data/libxlsxwriter/include/xlsxwriter.h +5 -4
  60. data/libxlsxwriter/libxlsxwriter.podspec +6 -6
  61. data/libxlsxwriter/src/Makefile +2 -1
  62. data/libxlsxwriter/src/app.c +2 -1
  63. data/libxlsxwriter/src/chart.c +360 -63
  64. data/libxlsxwriter/src/chartsheet.c +2 -1
  65. data/libxlsxwriter/src/comment.c +2 -1
  66. data/libxlsxwriter/src/content_types.c +22 -1
  67. data/libxlsxwriter/src/core.c +2 -1
  68. data/libxlsxwriter/src/custom.c +2 -1
  69. data/libxlsxwriter/src/drawing.c +7 -3
  70. data/libxlsxwriter/src/format.c +21 -1
  71. data/libxlsxwriter/src/hash_table.c +2 -1
  72. data/libxlsxwriter/src/metadata.c +176 -20
  73. data/libxlsxwriter/src/packager.c +306 -6
  74. data/libxlsxwriter/src/relationships.c +25 -1
  75. data/libxlsxwriter/src/rich_value.c +191 -0
  76. data/libxlsxwriter/src/rich_value_rel.c +142 -0
  77. data/libxlsxwriter/src/rich_value_structure.c +162 -0
  78. data/libxlsxwriter/src/rich_value_types.c +199 -0
  79. data/libxlsxwriter/src/shared_strings.c +2 -1
  80. data/libxlsxwriter/src/styles.c +31 -7
  81. data/libxlsxwriter/src/table.c +2 -1
  82. data/libxlsxwriter/src/theme.c +2 -1
  83. data/libxlsxwriter/src/utility.c +136 -46
  84. data/libxlsxwriter/src/vml.c +2 -1
  85. data/libxlsxwriter/src/workbook.c +191 -10
  86. data/libxlsxwriter/src/worksheet.c +514 -34
  87. data/libxlsxwriter/src/xmlwriter.c +17 -22
  88. data/libxlsxwriter/third_party/minizip/Makefile.orig +1 -1
  89. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  90. data/libxlsxwriter/third_party/minizip/ioapi.h +6 -6
  91. data/libxlsxwriter/third_party/minizip/miniunz.c +16 -2
  92. data/libxlsxwriter/third_party/minizip/unzip.c +4 -4
  93. data/libxlsxwriter/third_party/minizip/unzip.h +1 -1
  94. data/libxlsxwriter/third_party/minizip/zip.c +5 -5
  95. data/libxlsxwriter/third_party/minizip/zip.h +3 -3
  96. data/libxlsxwriter/version.txt +1 -1
  97. data/sonar-project.properties +4 -0
  98. data/test/color_to_hex_test.rb +15 -0
  99. data/test/comment_opt_test.rb +76 -0
  100. data/test/date_test.rb +14 -0
  101. data/test/format_test.rb +5 -1
  102. data/test/get_worksheet_test.rb +28 -0
  103. data/test/test_helper.rb +7 -4
  104. data/test/tmpdir_test.rb +32 -0
  105. data/test/validations_test.rb +25 -19
  106. data/test/worksheet_test.rb +10 -2
  107. metadata +42 -12
  108. data/libxlsxwriter/cmake/FindMINIZIP.cmake +0 -121
  109. data/libxlsxwriter/cmake/FindPackage.cmake +0 -183
  110. data/libxlsxwriter/cmake/i686-toolchain.cmake +0 -7
  111. data/test/reopen_test.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 792a2afe9492aeeaba9fbb65da941d2b604a2fd14bf934b17662fdf05281ac32
4
- data.tar.gz: 11795006b99d4fc9403fd3f85ab6babff417b1ed49341a2081073852063d2a71
3
+ metadata.gz: 4230ede32a57ecc66b00a96a722d61e52b37c4657ee64a2cbb42222f596113c3
4
+ data.tar.gz: 04d992357aa76f454775d62a2a14e7641e96908b6c56008fd53952dfbc8ca7d4
5
5
  SHA512:
6
- metadata.gz: 7215d937426efb2580ba947c727a60a519fb411a5504eb58162a1646057bd191812eae00394ac9c915a9f7f53a6acf6cfff66e4d773a8ac579bb3494164c3292
7
- data.tar.gz: 9f381f209a7d4f7c22a0994ed241b2be0a67d994c400f7867529fa1fa95fbc6326189a9dc53588f0bfbc376933ffab6fee4eaee37f7ac57d6a4f68a66295c8cc
6
+ metadata.gz: '08f05e65b527700c7b919f5ebd1c63cf6c65229a127ad4d15912021a2c6a5e4b9af09ed183efbbbfcd071d957bc828a72c522da251a81e5014f9b5fbd9666d77'
7
+ data.tar.gz: f45565c465f7f0107079737743a2b822308326fef5a4a5a1dc3ff254547f0d1cf1d11b88ea4099d01f36a442a3a20cb796318e4114be6cf9d3356b726ea06f1d
@@ -8,7 +8,7 @@ jobs:
8
8
  fail-fast: false
9
9
  matrix:
10
10
  os: [ubuntu-latest, macos-latest, windows-latest]
11
- ruby: [2.7, '3.0', 3.1, 3.2, 3.3]
11
+ ruby: ['2.7', '3.1', '3.3', '3.4', '4.0']
12
12
 
13
13
  runs-on: ${{ matrix.os }}
14
14
 
@@ -26,3 +26,7 @@ jobs:
26
26
  - run: rake test
27
27
  - run: rake examples
28
28
  - run: gem build fast_excel.gemspec
29
+
30
+ - name: Coverage Report by octocov
31
+ if: ${{ matrix.os == 'ubuntu-latest' && matrix.ruby == '3.4' }}
32
+ uses: k1LoW/octocov-action@v1
data/.gitignore CHANGED
@@ -20,3 +20,6 @@ ext/fast_excel/Makefile
20
20
  ext/fast_excel/text_width_ext.bundle
21
21
  Gemfile.lock
22
22
  lib/libxlsxwriter.dylib
23
+ coverage/
24
+ *.so
25
+ *.time
data/.octocov.yml ADDED
@@ -0,0 +1,28 @@
1
+ coverage:
2
+ paths:
3
+ - coverage/.resultset.json
4
+ codeToTestRatio:
5
+ code:
6
+ - '**/*.rb'
7
+ - '!test/**/*.rb'
8
+ test:
9
+ - 'test/**/*_test.rb'
10
+ testExecutionTime:
11
+ if: true
12
+ diff:
13
+ datastores:
14
+ - artifact://${GITHUB_REPOSITORY}
15
+ comment:
16
+ if: false
17
+ body:
18
+ if: true
19
+ #comment:
20
+ # if: is_pull_request
21
+ # deletePrevious: true
22
+ report:
23
+ if: is_default_branch
24
+ datastores:
25
+ - artifact://${GITHUB_REPOSITORY}
26
+ timeout: 5min
27
+ summary:
28
+ if: true
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ #### Version 0.6.1 - 19 oct 2026
2
+
3
+ * Fix segfault in `workbook#get_worksheet_by_name` when sheet does not exist (Thanks to @amberstarlight)
4
+ * Add support for `worksheet_write_comment_opt` with styled comments and hash options (Thanks to @ololoshka12345)
5
+ * Respect current environment's temp directory and add `tmpdir:` option to `FastExcel.open` (Thanks to @spyderdfx)
6
+ * Sync latest libxlsxwriter (v1.2.4)
7
+ * Support Ruby 4.0 and add to CI test matrix
8
+ * Add tests for `FastExcel.lxw_time`, `color_to_hex`, and pretty print improvements
9
+
1
10
  #### Version 0.5.0 - 02 jan 2024
2
11
 
3
12
  * Support ruby 3.3
data/Gemfile CHANGED
@@ -5,13 +5,15 @@ gemspec
5
5
  gem 'rake'
6
6
 
7
7
  gem 'roo'
8
+ gem 'csv'
9
+ gem 'bigdecimal'
8
10
 
11
+ gem 'simplecov', require: false
9
12
  gem 'minitest'
10
13
  gem 'minitest-reporters'
11
14
 
12
-
13
15
  group :benchmarks do
14
- gem 'axlsx', git: 'https://github.com/randym/axlsx.git'
16
+ gem 'caxlsx', git: 'https://github.com/caxlsx/caxlsx'
15
17
  gem 'write_xlsx'
16
18
  gem 'xlsxtream'
17
19
  gem 'benchmark-ips'
data/Rakefile CHANGED
@@ -19,9 +19,12 @@ end
19
19
 
20
20
  desc "Run all examples"
21
21
  task :examples do
22
+ require 'fileutils'
23
+ FileUtils.rm_f(Dir.glob('*.xlsx'))
22
24
  Dir.glob('examples/**/*.rb').each do |file|
23
- require './' + file.sub(/\.rb$/, '')
25
+ load './' + file
24
26
  end
27
+ FileUtils.rm_f(Dir.glob('*.xlsx'))
25
28
  end
26
29
 
27
30
  desc "Compile libxlsxwriter shared library"
@@ -0,0 +1,39 @@
1
+ require_relative '../lib/fast_excel'
2
+
3
+ workbook = FastExcel.open('comment_options.xlsx', constant_memory: true)
4
+ worksheet = workbook.add_worksheet('Comment Options')
5
+
6
+ worksheet.write_value(0, 0, 'Cell with basic comment')
7
+ worksheet.write_comment(0, 0, 'Very basic comment.')
8
+
9
+ options = Libxlsxwriter::CommentOptions.new
10
+ options.author = 'Lol'
11
+ options.visible = 1
12
+
13
+ worksheet.write_value(2, 0, 'Cell with visible comment and custom author')
14
+ worksheet.write_comment_opt(2, 0, 'This comment is visible and has a custom author', options)
15
+
16
+ options = Libxlsxwriter::CommentOptions.new
17
+ options.author = 'Kek'
18
+ options.width = 250
19
+ options.height = 100
20
+ options.color = '#FF0000'
21
+ options.font_name = 'Courier New'
22
+ options.font_size = 10.0
23
+ options.visible = 1
24
+
25
+ worksheet.write_value(5, 0, 'Cell with styled comment')
26
+ worksheet.write_comment_opt(5, 0, 'If a song plants an idea or a feeling in a mind, it has already changed the world.', options)
27
+
28
+ options = Libxlsxwriter::CommentOptions.new
29
+ options.start_row = 10
30
+ options.start_col = 2
31
+ options.x_offset = 20
32
+ options.y_offset = 20
33
+ options.visible = 1
34
+
35
+ worksheet.write_value(10, 0, 'Cell with repositioned comment')
36
+ worksheet.write_comment_opt(10, 0, 'This comment is positioned away from the cell.', options)
37
+
38
+ workbook.close
39
+ puts 'Saved to file comment_options.xlsx'
data/fast_excel.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "fast_excel"
3
- s.version = "0.5.0"
3
+ s.version = "0.6.1"
4
4
  s.author = ["Pavel Evstigneev"]
5
5
  s.email = ["pavel.evst@gmail.com"]
6
6
  s.homepage = "https://github.com/paxa/fast_excel"
@@ -15,5 +15,6 @@ Gem::Specification.new do |s|
15
15
  s.require_paths = ["lib"]
16
16
  s.extensions = ["extconf.rb"]
17
17
 
18
- s.add_runtime_dependency "ffi", ["> 1.9", "< 2"]
18
+ s.add_runtime_dependency "ffi", ["> 1.17", "< 2"]
19
+ s.add_runtime_dependency "base64", [">= 0.2", "< 2"]
19
20
  end
@@ -1,15 +1,52 @@
1
1
  module Libxlsxwriter
2
+ # Data converters
3
+ module UTF8StringPointer
4
+ extend FFI::DataConverter
5
+ native_type FFI::Type::POINTER
6
+
7
+ class << self
8
+ # Given either a String or nil, make an actual FFI::Pointer
9
+ # of that value.
10
+ #
11
+ # @param [#to_str, nil] value
12
+ # @param ctx
13
+ # @return [FFI::Pointer]
14
+ def to_native(value, ctx)
15
+ value && FFI::MemoryPointer.from_string(value.to_str.encode(Encoding::UTF_8))
16
+ end
17
+
18
+ # Given a pointer, read out it’s string.
19
+ #
20
+ # @param [FFI::Pointer] value
21
+ # @param ctx
22
+ # @return [String, nil]
23
+ def from_native(value, ctx)
24
+ value.read_string.force_encoding(Encoding::UTF_8) unless value.null?
25
+ end
26
+
27
+ # Used by FFI::StructLayoutField to know if this field
28
+ # requires the reference to be maintained by FFI. If we
29
+ # return false here, the MemoryPointer from to_native
30
+ # will be garbage collected before the struct.
31
+ def reference_required?
32
+ true
33
+ end
34
+ end
35
+ end
36
+
2
37
  # = Fields:
3
38
  # :constant_memory ::
4
39
  # (Integer) Optimize the workbook to use constant memory for worksheets
5
40
  # :tmpdir ::
6
41
  # (String) Directory to use for the temporary files created by libxlsxwriter.
7
42
  class WorkbookOptions < FFI::Struct
8
- layout :constant_memory, :uchar,
9
- :tmpdir, :string,
10
- :use_zip64, :uchar,
11
- :output_buffer, :pointer,
12
- :output_buffer_size, :pointer
43
+ conf = {}
44
+ conf[:constant_memory] = :uchar
45
+ conf[:tmpdir] = UTF8StringPointer
46
+ conf[:use_zip64] = :uchar
47
+ conf[:output_buffer] = :pointer
48
+ conf[:output_buffer_size] = :pointer
49
+ layout(conf)
13
50
  end
14
51
 
15
52
  # = Fields:
@@ -143,7 +180,8 @@ module Libxlsxwriter
143
180
  # @param [String] name
144
181
  # @return [Worksheet]
145
182
  def get_worksheet_by_name(name)
146
- Worksheet.new Libxlsxwriter.workbook_get_worksheet_by_name(self, name)
183
+ ptr = Libxlsxwriter.workbook_get_worksheet_by_name(self, name)
184
+ ptr.null? ? nil : Worksheet.new(ptr)
147
185
  end
148
186
 
149
187
  # @param [String] sheetname
@@ -177,6 +215,7 @@ module Libxlsxwriter
177
215
  :worksheet_names, WorksheetNames.ptr,
178
216
  :chartsheet_names, :pointer,
179
217
  :image_md5s, :pointer,
218
+ :embedded_image_md5s, :pointer,
180
219
  :header_image_md5s, :pointer,
181
220
  :background_md5s, :pointer,
182
221
  :charts, Charts.ptr,
@@ -199,6 +238,9 @@ module Libxlsxwriter
199
238
  :num_format_count, :uint16,
200
239
  :drawing_count, :uint16,
201
240
  :comment_count, :uint16,
241
+ :num_embedded_images, :uint32,
242
+ :window_width, :uint16,
243
+ :window_height, :uint16,
202
244
 
203
245
  :font_count, :uint16,
204
246
  :border_count, :uint16,
@@ -214,6 +256,9 @@ module Libxlsxwriter
214
256
  :has_vml, :uchar,
215
257
  :has_comments, :uchar,
216
258
  :has_metadata, :uchar,
259
+ :has_embedded_images, :uchar,
260
+ :has_dynamic_functions, :uchar,
261
+ :has_embedded_image_descriptions, :uchar,
217
262
 
218
263
  :used_xf_formats, HashTable.ptr,
219
264
  :used_dxf_formats, HashTable.ptr,
@@ -222,6 +267,8 @@ module Libxlsxwriter
222
267
  :vba_project_signature, :string,
223
268
  :vba_codename, :string,
224
269
 
270
+ :use_1904_epoch, :uchar,
271
+
225
272
  :default_url_format, :pointer
226
273
  end
227
274
 
@@ -210,8 +210,22 @@ module Libxlsxwriter
210
210
  Libxlsxwriter.worksheet_write_string(self, row, col, string, format)
211
211
  end
212
212
 
213
- def write_comment(row, col, string)
214
- Libxlsxwriter.worksheet_write_comment(self, row, col, string)
213
+ def write_comment(row, col, string, options = nil)
214
+ if options
215
+ write_comment_opt(row, col, string, options)
216
+ else
217
+ Libxlsxwriter.worksheet_write_comment(self, row, col, string)
218
+ end
219
+ end
220
+
221
+ # @param [Integer] row
222
+ # @param [Integer] col
223
+ # @param [String] string
224
+ # @param [CommentOptions, Hash] options
225
+ # @return [Symbol from _enum_error_]
226
+ def write_comment_opt(row, col, string, options)
227
+ options = Libxlsxwriter::CommentOptions.new(options) if options.is_a?(Hash)
228
+ Libxlsxwriter.worksheet_write_comment_opt(self, row, col, string, options)
215
229
  end
216
230
 
217
231
  # @param [Integer] row
@@ -695,11 +709,11 @@ module Libxlsxwriter
695
709
  :comments, TableRows.ptr,
696
710
  :array, :pointer,
697
711
  :merged_ranges, MergedRanges.ptr,
698
- #:selections, Selections.ptr,
712
+ :selections, :pointer,
699
713
  :data_validations, :pointer, # TODO add real definition for lxw_data_validations
700
714
  :conditional_formats, :pointer,
701
715
  :image_props, :pointer,
702
- :image_data, ImageData.ptr,
716
+ :embedded_image_props, :pointer,
703
717
  :chart_data, ChartData.ptr,
704
718
  :drawing_rel_ids, :pointer,
705
719
  :vml_drawing_rel_ids, :pointer,
@@ -1032,6 +1046,16 @@ module Libxlsxwriter
1032
1046
 
1033
1047
  attach_function :worksheet_write_comment, :worksheet_write_comment, [Worksheet, :uint32, :ushort, :string], :error
1034
1048
 
1049
+ # @method worksheet_write_comment_opt(worksheet, row, col, string, options)
1050
+ # @param [Worksheet] worksheet
1051
+ # @param [Integer] row
1052
+ # @param [Integer] col
1053
+ # @param [String] string
1054
+ # @param [CommentOptions] options
1055
+ # @return [Symbol from _enum_error_]
1056
+ # @scope class
1057
+ attach_function :worksheet_write_comment_opt, :worksheet_write_comment_opt, [Worksheet, :uint32, :ushort, :string, CommentOptions], :error
1058
+
1035
1059
  # @method worksheet_write_formula(worksheet, row, col, formula, format)
1036
1060
  # @param [Worksheet] worksheet
1037
1061
  # @param [Integer] row
@@ -330,19 +330,22 @@ module Libxlsxwriter
330
330
  :error_feature_not_supported, 11,
331
331
  :error_null_parameter_ignored, 12,
332
332
  :error_parameter_validation, 13,
333
- :error_sheetname_length_exceeded, 14,
334
- :error_invalid_sheetname_character, 15,
335
- :error_sheetname_start_end_apostrophe, 16,
336
- :error_sheetname_already_used, 17,
337
- :error_32_string_length_exceeded, 18,
338
- :error_128_string_length_exceeded, 19,
339
- :error_255_string_length_exceeded, 20,
340
- :error_max_string_length_exceeded, 21,
341
- :error_shared_string_index_not_found, 22,
342
- :error_worksheet_index_out_of_range, 23,
343
- :error_worksheet_max_number_urls_exceeded, 24,
344
- :error_image_dimensions, 25,
345
- :max_errno, 26
333
+ :error_parameter_is_empty, 14,
334
+ :error_datetime_validation, 15,
335
+ :error_sheetname_length_exceeded, 16,
336
+ :error_invalid_sheetname_character, 17,
337
+ :error_sheetname_start_end_apostrophe, 18,
338
+ :error_sheetname_already_used, 19,
339
+ :error_32_string_length_exceeded, 20,
340
+ :error_128_string_length_exceeded, 21,
341
+ :error_255_string_length_exceeded, 22,
342
+ :error_max_string_length_exceeded, 23,
343
+ :error_shared_string_index_not_found, 24,
344
+ :error_worksheet_index_out_of_range, 25,
345
+ :error_worksheet_max_url_length_exceeded, 26,
346
+ :error_worksheet_max_number_urls_exceeded, 27,
347
+ :error_image_dimensions, 28,
348
+ :max_errno, 29
346
349
  ]
347
350
 
348
351
  # = Fields:
@@ -1153,6 +1156,106 @@ module Libxlsxwriter
1153
1156
  :collapsed, :uchar
1154
1157
  end
1155
1158
 
1159
+ # = Fields:
1160
+ # :visible ::
1161
+ # (Integer) Make the comment visible.
1162
+ # :author ::
1163
+ # (String) Author of the comment.
1164
+ # :width ::
1165
+ # (Integer) Width of the comment box.
1166
+ # :height ::
1167
+ # (Integer) Height of the comment box.
1168
+ # :x_scale ::
1169
+ # (Float) X scale of the comment.
1170
+ # :y_scale ::
1171
+ # (Float) Y scale of the comment.
1172
+ # :color ::
1173
+ # (Integer) Background color of the comment box.
1174
+ # :font_name ::
1175
+ # (String) Font name for the comment.
1176
+ # :font_size ::
1177
+ # (Float) Font size for the comment.
1178
+ # :font_family ::
1179
+ # (Integer) Font family for the comment.
1180
+ # :start_row ::
1181
+ # (Integer) Start row for the comment box.
1182
+ # :start_col ::
1183
+ # (Integer) Start column for the comment box.
1184
+ # :x_offset ::
1185
+ # (Integer) X offset for the comment box.
1186
+ # :y_offset ::
1187
+ # (Integer) Y offset for the comment box.
1188
+ class CommentOptions < FFI::Struct
1189
+ layout :visible, :uchar,
1190
+ :author, :pointer,
1191
+ :width, :ushort,
1192
+ :height, :ushort,
1193
+ :x_scale, :double,
1194
+ :y_scale, :double,
1195
+ :color, :uint32,
1196
+ :font_name, :pointer,
1197
+ :font_size, :double,
1198
+ :font_family, :uchar,
1199
+ :start_row, :uint32,
1200
+ :start_col, :ushort,
1201
+ :x_offset, :int32,
1202
+ :y_offset, :int32
1203
+
1204
+ def initialize(*args)
1205
+ if args.first.is_a?(Hash)
1206
+ super()
1207
+ @pointers = {}
1208
+ set(args.first)
1209
+ else
1210
+ super(*args)
1211
+ @pointers = {}
1212
+ end
1213
+ end
1214
+
1215
+ def set(options)
1216
+ options.each do |k, v|
1217
+ send("#{k}=", v) if respond_to?("#{k}=")
1218
+ end
1219
+ self
1220
+ end
1221
+
1222
+ [:visible, :width, :height, :x_scale, :y_scale, :font_size, :font_family, :start_row, :start_col, :x_offset, :y_offset].each do |prop|
1223
+ define_method(prop) do
1224
+ self[prop]
1225
+ end
1226
+ define_method("#{prop}=") do |value|
1227
+ self[prop] = value
1228
+ end
1229
+ end
1230
+
1231
+ [:author, :font_name].each do |prop|
1232
+ define_method(prop) do
1233
+ ptr = self[prop]
1234
+ ptr.read_string unless ptr.null?
1235
+ end
1236
+
1237
+ define_method("#{prop}=") do |value|
1238
+ @pointers ||= {}
1239
+ if value.nil?
1240
+ @pointers.delete(prop)
1241
+ self[prop] = nil
1242
+ else
1243
+ ptr = FFI::MemoryPointer.from_string(value.to_s)
1244
+ @pointers[prop] = ptr
1245
+ self[prop] = ptr
1246
+ end
1247
+ end
1248
+ end
1249
+
1250
+ def color
1251
+ self[:color]
1252
+ end
1253
+
1254
+ def color=(value)
1255
+ self[:color] = FastExcel.color_to_hex(value)
1256
+ end
1257
+ end
1258
+
1156
1259
  require_relative 'binding/format'
1157
1260
 
1158
1261
  #
data/lib/fast_excel.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require_relative './fast_excel/binding'
2
2
  require 'set'
3
-
4
- # not used for now
5
- #require_relative '../ext/fast_excel/text_width_ext'
3
+ require 'tmpdir'
6
4
 
7
5
  module FastExcel
8
6
 
@@ -22,14 +20,13 @@ module FastExcel
22
20
 
23
21
  DEF_COL_WIDTH = 8.43
24
22
 
25
- def self.open(filename = nil, constant_memory: false, default_format: nil)
23
+ def self.open(filename = nil, constant_memory: false, default_format: nil, tmpdir: nil)
26
24
  tmp_file = false
27
25
  if filename
28
26
  if File.exist?(filename) && File.size(filename) > 0
29
27
  raise ArgumentError, "File '#{filename}' already exists. FastExcel can not open existing files, only create new files"
30
28
  end
31
29
  else
32
- require 'tmpdir'
33
30
  filename = "#{Dir.mktmpdir}/fast_excel.xlsx"
34
31
  tmp_file = true
35
32
  end
@@ -38,6 +35,7 @@ module FastExcel
38
35
 
39
36
  opt = Libxlsxwriter::WorkbookOptions.new
40
37
  opt[:constant_memory] = constant_memory ? 1 : 0
38
+ opt[:tmpdir] = tmpdir || Dir.tmpdir
41
39
  workbook = Libxlsxwriter.workbook_new_opt(filename, opt)
42
40
 
43
41
  result = Libxlsxwriter::Workbook.new(workbook)
@@ -295,8 +293,8 @@ module FastExcel
295
293
  return EXTRA_COLORS[value.to_sym]
296
294
  elsif COLOR_ENUM.find(value.to_sym)
297
295
  return COLOR_ENUM.find(value.to_sym)
298
- elsif COLOR_ENUM.find("color_#{value.to_sym}")
299
- return COLOR_ENUM.find("color_#{value.to_sym}")
296
+ elsif COLOR_ENUM.find("color_#{value}".to_sym)
297
+ return COLOR_ENUM.find("color_#{value}".to_sym)
300
298
  elsif value =~ /^#?(0x)?([\da-f]){6}$/i
301
299
  value = value.sub('#', '') if value.start_with?('#')
302
300
  return value.start_with?('0x') ? value.to_i(16) : "0x#{value}".to_i(16)
@@ -334,8 +332,8 @@ module FastExcel
334
332
  res
335
333
  end
336
334
 
337
- def pretty_print(pp)
338
- pp fields_hash
335
+ def pretty_print(pp_obj)
336
+ fields_hash.pretty_print(pp_obj)
339
337
  end
340
338
  end
341
339
 
@@ -390,9 +388,12 @@ module FastExcel
390
388
  end
391
389
 
392
390
  def get_worksheet_by_name(name)
393
- sheet = super(name)
394
- sheet.workbook = self
391
+ return nil if name.nil? || !@sheet_names.include?(name.to_s)
395
392
 
393
+ sheet = super(name.to_s)
394
+ return nil if sheet.nil?
395
+
396
+ sheet.workbook = self
396
397
  sheet
397
398
  end
398
399
 
@@ -543,7 +544,7 @@ module FastExcel
543
544
  end
544
545
 
545
546
  def enable_filters!(start_col: 0, end_col:)
546
- autofilter(start_col, 0, @last_row_number, end_col)
547
+ autofilter(0, start_col, @last_row_number, end_col)
547
548
  end
548
549
 
549
550
  def close
@@ -0,0 +1,9 @@
1
+ FreeBSD_task:
2
+ freebsd_instance:
3
+ image_family: freebsd-14-0
4
+ setup_script:
5
+ pkg install -y gmake devel/py-pytest
6
+ build_script:
7
+ gmake
8
+ test_script:
9
+ gmake test
@@ -36,13 +36,17 @@ jobs:
36
36
  sudo apt-get -y install libssl-dev
37
37
 
38
38
  - name: Configure CMake
39
- working-directory: ${{ github.workspace }}/cmake
40
- run: cmake .. -DBUILD_TESTS=ON ${{ matrix.cmake_flags }} -DCMAKE_BUILD_TYPE=Release
39
+ run: |
40
+ mkdir build
41
+ cd build
42
+ cmake .. -DBUILD_TESTS=ON ${{ matrix.cmake_flags }} -DCMAKE_BUILD_TYPE=Release
41
43
 
42
44
  - name: Build
43
- working-directory: ${{ github.workspace }}/cmake
44
- run: cmake --build . --config Release --parallel
45
+ run: |
46
+ cd build
47
+ cmake --build . --config Release --parallel
45
48
 
46
49
  - name: Test
47
- working-directory: ${{ github.workspace }}/cmake
48
- run: ctest -C Release -V
50
+ run: |
51
+ cd build
52
+ ctest -C Release -V
@@ -16,6 +16,8 @@ jobs:
16
16
  run: |
17
17
  sudo apt-get -y install indent
18
18
  sudo ln -s /usr/bin/indent /usr/bin/gindent
19
+ python -m pip install --upgrade pip
20
+ pip install gersemi
19
21
 
20
22
  - name: Make indent
21
23
  run: |
@@ -0,0 +1,43 @@
1
+ name: Test Make 32bit build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name:
8
+ Make
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ cc: [gcc, clang]
13
+ make_flags: ["CFLAGS=-m32",
14
+ "CFLAGS=-m32 USE_STANDARD_TMPFILE=1",
15
+ "CFLAGS=-m32 USE_DTOA_LIBRARY=1",
16
+ "CFLAGS=-m32 USE_NO_MD5=1",
17
+ "CFLAGS=-m32 USE_MEM_FILE=1"]
18
+ runs-on: ubuntu-latest
19
+ env:
20
+ CC: ${{ matrix.cc }}
21
+ CXX: ${{ matrix.cc }}
22
+ CFLAGS: '-Werror'
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+
27
+ - name: Install dependencies
28
+ run: |
29
+ python -m pip install --upgrade pip
30
+ pip install pytest
31
+ sudo dpkg --add-architecture i386
32
+ sudo apt update
33
+ sudo apt-get -y install gcc-multilib
34
+ sudo apt-get -y install zlib1g-dev:i386
35
+
36
+ - name: make
37
+ run: ${{ matrix.make_flags }} make V=1
38
+
39
+ - name: test functional
40
+ run: ${{ matrix.make_flags }} make test_functional V=1 -j
41
+
42
+ - name: test examples
43
+ run: ${{ matrix.make_flags }} make examples V=1
@@ -11,8 +11,8 @@ jobs:
11
11
  matrix:
12
12
  cmake_flags: ["-DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON",
13
13
  "-DUSE_DTOA_LIBRARY=ON -DBUILD_TESTS=ON",
14
- #"-DUSE_SYSTEM_MINIZIP=ON -DBUILD_TESTS=ON",
15
- #"-DUSE_SYSTEM_MINIZIP=ON -DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
14
+ "-DUSE_SYSTEM_MINIZIP=ON -DBUILD_TESTS=ON",
15
+ "-DUSE_SYSTEM_MINIZIP=ON -DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
16
16
  "-DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
17
17
  ]
18
18
 
@@ -33,7 +33,8 @@ jobs:
33
33
  working-directory: ${{env.GITHUB_WORKSPACE}}
34
34
  shell: cmd
35
35
  run: |
36
- cd cmake
36
+ mkdir build
37
+ cd build
37
38
  call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
38
39
  cmake .. -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_flags }} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -A x64
39
40
 
@@ -41,7 +42,7 @@ jobs:
41
42
  working-directory: ${{env.GITHUB_WORKSPACE}}
42
43
  shell: cmd
43
44
  run: |
44
- cd cmake
45
+ cd build
45
46
  call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
46
47
  cmake --build . --config Release
47
48
 
@@ -49,6 +50,6 @@ jobs:
49
50
  working-directory: ${{env.GITHUB_WORKSPACE}}
50
51
  shell: cmd
51
52
  run: |
52
- cd cmake
53
- copy test\functional\src\Release\*.exe test\functional\src
53
+ cd build
54
+ copy test\functional\src\Release\*.* test\functional\src
54
55
  pytest -v test/functional