fast_excel 0.4.1 → 0.6.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.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +4 -6
  3. data/.gitignore +3 -0
  4. data/.octocov.yml +28 -0
  5. data/CHANGELOG.md +16 -0
  6. data/Gemfile +5 -3
  7. data/examples/comment_options.rb +39 -0
  8. data/examples/example.rb +2 -0
  9. data/examples/example_date_time.rb +38 -0
  10. data/fast_excel.gemspec +4 -3
  11. data/lib/fast_excel/binding/format.rb +17 -0
  12. data/lib/fast_excel/binding/workbook.rb +80 -20
  13. data/lib/fast_excel/binding/worksheet.rb +81 -13
  14. data/lib/fast_excel/binding.rb +107 -7
  15. data/lib/fast_excel.rb +40 -32
  16. data/libxlsxwriter/.github/FUNDING.yml +1 -0
  17. data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
  18. data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
  19. data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
  20. data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
  21. data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
  22. data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
  23. data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
  24. data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
  25. data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
  26. data/libxlsxwriter/.gitignore +16 -1
  27. data/libxlsxwriter/.indent.pro +24 -0
  28. data/libxlsxwriter/CMakeLists.txt +156 -56
  29. data/libxlsxwriter/CONTRIBUTING.md +2 -2
  30. data/libxlsxwriter/Changes.txt +344 -2
  31. data/libxlsxwriter/LICENSE.txt +66 -8
  32. data/libxlsxwriter/Makefile +151 -54
  33. data/libxlsxwriter/Package.swift +42 -0
  34. data/libxlsxwriter/Readme.md +4 -2
  35. data/libxlsxwriter/build.zig +324 -0
  36. data/libxlsxwriter/build.zig.zon +11 -0
  37. data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
  38. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
  39. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  40. data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
  41. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
  42. data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  43. data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
  44. data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
  45. data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  46. data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  47. data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
  48. data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
  49. data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  50. data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
  51. data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
  52. data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  53. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  54. data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
  55. data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
  56. data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  57. data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
  58. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
  59. data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
  60. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
  61. data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
  62. data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  63. data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
  64. data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
  65. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
  66. data/libxlsxwriter/include/xlsxwriter.h +4 -2
  67. data/libxlsxwriter/libxlsxwriter.podspec +8 -5
  68. data/libxlsxwriter/src/Makefile +58 -21
  69. data/libxlsxwriter/src/app.c +5 -2
  70. data/libxlsxwriter/src/chart.c +396 -81
  71. data/libxlsxwriter/src/chartsheet.c +22 -22
  72. data/libxlsxwriter/src/comment.c +443 -0
  73. data/libxlsxwriter/src/content_types.c +40 -1
  74. data/libxlsxwriter/src/core.c +2 -2
  75. data/libxlsxwriter/src/custom.c +1 -1
  76. data/libxlsxwriter/src/drawing.c +160 -40
  77. data/libxlsxwriter/src/format.c +109 -25
  78. data/libxlsxwriter/src/hash_table.c +1 -1
  79. data/libxlsxwriter/src/metadata.c +283 -0
  80. data/libxlsxwriter/src/packager.c +794 -94
  81. data/libxlsxwriter/src/relationships.c +1 -1
  82. data/libxlsxwriter/src/shared_strings.c +2 -4
  83. data/libxlsxwriter/src/styles.c +353 -58
  84. data/libxlsxwriter/src/table.c +304 -0
  85. data/libxlsxwriter/src/theme.c +1 -1
  86. data/libxlsxwriter/src/utility.c +143 -43
  87. data/libxlsxwriter/src/vml.c +1062 -0
  88. data/libxlsxwriter/src/workbook.c +567 -77
  89. data/libxlsxwriter/src/worksheet.c +6668 -1462
  90. data/libxlsxwriter/src/xmlwriter.c +95 -5
  91. data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
  92. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
  93. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
  94. data/libxlsxwriter/third_party/md5/Makefile +42 -0
  95. data/libxlsxwriter/third_party/md5/md5.c +291 -0
  96. data/libxlsxwriter/third_party/md5/md5.h +45 -0
  97. data/libxlsxwriter/third_party/minizip/Makefile +3 -8
  98. data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
  99. data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
  100. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  101. data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
  102. data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
  103. data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
  104. data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
  105. data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
  106. data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
  107. data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
  108. data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
  109. data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
  110. data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
  111. data/libxlsxwriter/third_party/minizip/zip.c +165 -218
  112. data/libxlsxwriter/third_party/minizip/zip.h +164 -154
  113. data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
  114. data/libxlsxwriter/version.txt +1 -1
  115. data/sonar-project.properties +4 -0
  116. data/test/auto_width_test.rb +20 -0
  117. data/test/color_to_hex_test.rb +15 -0
  118. data/test/comment_opt_test.rb +76 -0
  119. data/test/date_test.rb +14 -0
  120. data/test/default_format_test.rb +1 -1
  121. data/test/format_test.rb +5 -1
  122. data/test/get_worksheet_test.rb +28 -0
  123. data/test/test_helper.rb +7 -4
  124. data/test/tmpdir_test.rb +32 -0
  125. data/test/validations_test.rb +25 -19
  126. data/test/worksheet_test.rb +6 -1
  127. metadata +62 -13
  128. data/libxlsxwriter/.travis.yml +0 -37
  129. data/test/reopen_test.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81f6dc41f599591425a032e95046733c9a27b7b44e5f6d15f71c9040e1452eaf
4
- data.tar.gz: 05ce040ed72e6c056311177c5753d6f363d8750515502054648cac440d3cde09
3
+ metadata.gz: f3735cb9c55d31df98975baa51a0547f67ca33fb1519b7bbd986af3ea9d78658
4
+ data.tar.gz: 9e79dcc1be146f889e86f373d87959754b1ffbfb4a617cbf363db04652fbfc45
5
5
  SHA512:
6
- metadata.gz: f614c8458db906397a2c27825c302e4a0d7a3f2958ed7053a33c9bd2dcbfd063fd27e5a6a8b1a7b3d230afc23919f359d27e61b785ded07b6cf95de55081d711
7
- data.tar.gz: cbc0d5436ddde9052359e069a2d4e706810b9bd9ed28c544eca6e072566d32af9fba8b762cb47c011400d676dc71d7b641902058758f97cab98f44a9baef5ff9
6
+ metadata.gz: b91c2d94389477e2aa48ecf5354783c5ad4d003f20646e1ee9265a2d79ff88c66811465755b9dd62f32691d3caab4f4fb04c708722da4cc41b70b7de29f2167b
7
+ data.tar.gz: f84e5a0db01a38502b1325ec019725ada1ab87700d79ecfded77570d495da12b533387e963439bde75b93b9168cf6e899e16091bf2bf4c024d621ca2ede250c9
@@ -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]
11
+ ruby: [2.7, 3.1, 3.3, 3.4]
12
12
 
13
13
  runs-on: ${{ matrix.os }}
14
14
 
@@ -27,8 +27,6 @@ jobs:
27
27
  - run: rake examples
28
28
  - run: gem build fast_excel.gemspec
29
29
 
30
-
31
- gobills-critical
32
- gp-di-critical
33
-
34
- gp-di-alert
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,19 @@
1
+ #### Version 0.6.0 - 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
+ * Add tests for `FastExcel.lxw_time`, `color_to_hex`, and pretty print improvements
7
+
8
+ #### Version 0.5.0 - 02 jan 2024
9
+
10
+ * Support ruby 3.3
11
+ * Sync latest libxlsxwriter
12
+ * Add support for writing cell comments
13
+ * Add more examples
14
+ * Fix compilation of minizip on NixOS (Thanks to @Mange)
15
+ * On close set empty columns to default width (Thanks to @steffansluis)
16
+
1
17
  #### Version 0.4.1 - 13 jan 2023
2
18
 
3
19
  * Support ruby 3.2
data/Gemfile CHANGED
@@ -4,14 +4,16 @@ gemspec
4
4
 
5
5
  gem 'rake'
6
6
 
7
- gem 'roo', '2.8.3', git: 'https://github.com/roo-rb/roo.git', tag: 'v2.8.3'
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'
@@ -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/examples/example.rb CHANGED
@@ -22,6 +22,8 @@ worksheet.set_column(2, 2, 20, date_format)
22
22
 
23
23
  worksheet.write_row(0, ["message", "price", "date", "complete"], bold)
24
24
 
25
+ worksheet.write_comment(2, 2, "Comment to field")
26
+
25
27
  for i in 1..1000
26
28
  worksheet.write_row(i, ["Hello", (rand * 10_000_000).round(2), Time.now, i % 2 == 0])
27
29
 
@@ -0,0 +1,38 @@
1
+ require_relative '../lib/fast_excel'
2
+
3
+ require 'date'
4
+ require 'time'
5
+
6
+
7
+ File.unlink("example_date_time.xlsx") if File.exist?("example_date_time.xlsx")
8
+
9
+ workbook = FastExcel.open("example_date_time.xlsx", constant_memory: true)
10
+ workbook.default_format.set(
11
+ font_size: 0, # user's default
12
+ )
13
+ worksheet = workbook.add_worksheet
14
+
15
+ worksheet.set_columns_width(0, 4, 25)
16
+ worksheet.set_column(1, 1, 25, workbook.number_format("[$-409]m/d/yy hh:mm;@"))
17
+
18
+ intro = "Date and time in excel file stored as decimal number, it show number of days since January 1900, decimal part is for time of the day"
19
+ worksheet.merge_range(0, 0, 0, 4, intro, nil)
20
+ worksheet.write_value(1, 0, "")
21
+
22
+ worksheet.append_row(['', 'Formatted as Date', 'No formatting, plain number'])
23
+
24
+ worksheet.append_row(["Time.now", Time.now, Time.now, 'local timezone'])
25
+ worksheet.append_row(["Time.now.utc", Time.now.utc, Time.now.utc, 'UTC timezone'])
26
+
27
+ worksheet.append_row(["DateTime.now", DateTime.now, DateTime.now, 'local timezone'])
28
+ dt = DateTime.now.new_offset("+02:00")
29
+ worksheet.append_row(["DateTime new_offset", dt, dt, 'GMT+2 timezone'])
30
+
31
+ today = Date.today
32
+ worksheet.append_row(["Date.today", today, today])
33
+
34
+ worksheet.append_row(["0 (just zero)", 0, 0, '00 January 1900'])
35
+
36
+
37
+ workbook.close
38
+ puts "Saved to file example_date_time.xlsx"
data/fast_excel.gemspec CHANGED
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "fast_excel"
3
- s.version = "0.4.1"
3
+ s.version = "0.6.0"
4
4
  s.author = ["Pavel Evstigneev"]
5
5
  s.email = ["pavel.evst@gmail.com"]
6
6
  s.homepage = "https://github.com/paxa/fast_excel"
7
7
  s.summary = %q{Ultra Fast Excel Writer}
8
8
  s.description = "Wrapper for libxlsxwriter using ffi"
9
9
  s.license = 'MIT'
10
- s.required_ruby_version = ['>= 2.0', '< 4.0']
10
+ s.required_ruby_version = ['>= 2.0']
11
11
 
12
12
  s.files = `git ls-files`.split("\n")
13
13
  s.test_files = []
@@ -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
@@ -697,9 +697,14 @@ module Libxlsxwriter
697
697
  include FormatWrappers
698
698
  layout :file, :pointer,
699
699
  :xf_format_indices, :pointer, #HashTable.ptr,
700
+ :dxf_format_indices, :pointer,
700
701
  :num_xf_formats, :pointer,
702
+ :num_dxf_formats, :pointer,
703
+
701
704
  :xf_index, :int32_t,
702
705
  :dxf_index, :int32_t,
706
+ :xf_id, :int32_t,
707
+
703
708
  :num_format, [:char, 128],
704
709
  :font_name, [:char, 128],
705
710
  :font_scheme, [:char, 128],
@@ -708,6 +713,7 @@ module Libxlsxwriter
708
713
  :has_font, :uchar,
709
714
  :has_dxf_font, :uchar,
710
715
  :font_size, :double,
716
+
711
717
  :bold, :uchar,
712
718
  :italic, :uchar,
713
719
  :font_color, :int,
@@ -722,24 +728,32 @@ module Libxlsxwriter
722
728
  :font_extend, :uchar,
723
729
  :theme, :uchar,
724
730
  :hyperlink, :uchar,
731
+
725
732
  :hidden, :uchar,
726
733
  :locked, :uchar,
734
+
727
735
  :text_h_align, :uchar,
728
736
  :text_wrap, :uchar,
729
737
  :text_v_align, :uchar,
730
738
  :text_justlast, :uchar,
731
739
  :rotation, :short,
740
+
732
741
  :fg_color, :int,
733
742
  :bg_color, :int,
743
+ :dxf_fg_color, :int,
744
+ :dxf_bg_color, :int,
745
+
734
746
  :pattern, :uchar,
735
747
  :has_fill, :uchar,
736
748
  :has_dxf_fill, :uchar,
737
749
  :fill_index, :int,
738
750
  :fill_count, :int,
751
+
739
752
  :border_index, :int,
740
753
  :has_border, :uchar,
741
754
  :has_dxf_border, :uchar,
742
755
  :border_count, :int,
756
+
743
757
  :bottom, :uchar,
744
758
  :diag_border, :uchar,
745
759
  :diag_type, :uchar,
@@ -751,6 +765,7 @@ module Libxlsxwriter
751
765
  :left_color, :int,
752
766
  :right_color, :int,
753
767
  :top_color, :int,
768
+
754
769
  :indent, :uchar,
755
770
  :shrink, :uchar,
756
771
  :merge_range, :uchar,
@@ -758,6 +773,8 @@ module Libxlsxwriter
758
773
  :just_distrib, :uchar,
759
774
  :color_indexed, :uchar,
760
775
  :font_only, :uchar,
776
+
777
+ :quote_prefix, :uchar,
761
778
  :list_pointers, FormatListPointers.by_value
762
779
  end
763
780
 
@@ -1,13 +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
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)
11
50
  end
12
51
 
13
52
  # = Fields:
@@ -141,7 +180,8 @@ module Libxlsxwriter
141
180
  # @param [String] name
142
181
  # @return [Worksheet]
143
182
  def get_worksheet_by_name(name)
144
- 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)
145
185
  end
146
186
 
147
187
  # @param [String] sheetname
@@ -174,6 +214,9 @@ module Libxlsxwriter
174
214
  :chartsheets, :pointer,
175
215
  :worksheet_names, WorksheetNames.ptr,
176
216
  :chartsheet_names, :pointer,
217
+ :image_md5s, :pointer,
218
+ :header_image_md5s, :pointer,
219
+ :background_md5s, :pointer,
177
220
  :charts, Charts.ptr,
178
221
  :ordered_charts, Charts.ptr,
179
222
  :formats, Formats.ptr,
@@ -181,26 +224,43 @@ module Libxlsxwriter
181
224
  :sst, Sst.ptr,
182
225
  :properties, DocProperties.ptr,
183
226
  :custom_properties, CustomProperties.ptr,
184
- :filename, :pointer,
227
+ :filename, :string,
185
228
  :options, WorkbookOptions.by_value,
186
- :num_sheets, :uint16,
187
- :num_worksheets, :uint16,
188
- :num_chartsheets, :uint16,
189
- :first_sheet, :uint16,
190
- :active_sheet, :uint16,
191
- :num_xf_formats, :uint16,
229
+
230
+ :num_sheets, :uint16,
231
+ :num_worksheets, :uint16,
232
+ :num_chartsheets, :uint16,
233
+ :first_sheet, :uint16,
234
+ :active_sheet, :uint16,
235
+ :num_xf_formats, :uint16,
236
+ :num_dxf_formats, :uint16,
192
237
  :num_format_count, :uint16,
193
- :drawing_count, :uint16,
194
- :font_count, :uint16,
195
- :border_count, :uint16,
196
- :fill_count, :uint16,
197
- :optimize, :uchar,
198
- :has_png, :uchar,
238
+ :drawing_count, :uint16,
239
+ :comment_count, :uint16,
240
+
241
+ :font_count, :uint16,
242
+ :border_count, :uint16,
243
+ :fill_count, :uint16,
244
+ :optimize, :uchar,
245
+ :max_url_length, :uint16,
246
+ :read_only, :uchar,
247
+
248
+ :has_png, :uchar,
199
249
  :has_jpeg, :uchar,
200
- :has_bmp, :uchar,
250
+ :has_bmp, :uchar,
251
+ :has_gif, :uchar,
252
+ :has_vml, :uchar,
253
+ :has_comments, :uchar,
254
+ :has_metadata, :uchar,
255
+
201
256
  :used_xf_formats, HashTable.ptr,
202
- :vba_project, :pointer,
203
- :vba_codename, :pointer
257
+ :used_dxf_formats, HashTable.ptr,
258
+
259
+ :vba_project, :string,
260
+ :vba_project_signature, :string,
261
+ :vba_codename, :string,
262
+
263
+ :default_url_format, :pointer
204
264
  end
205
265
 
206
266
  attach_function :workbook_default_format, :workbook_default_format, [Workbook], Format
@@ -209,7 +209,25 @@ module Libxlsxwriter
209
209
  def write_string(row, col, string, format)
210
210
  Libxlsxwriter.worksheet_write_string(self, row, col, string, format)
211
211
  end
212
-
212
+
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)
229
+ end
230
+
213
231
  # @param [Integer] row
214
232
  # @param [Integer] col
215
233
  # @param [String] formula
@@ -684,29 +702,45 @@ module Libxlsxwriter
684
702
  include WorksheetWrappers
685
703
  layout :file, :pointer,
686
704
  :optimize_tmpfile, :pointer,
705
+ :optimize_buffer, :pointer,
706
+ :optimize_buffer_size, :size_t,
687
707
  :table, TableRows.ptr,
688
708
  :hyperlinks, TableRows.ptr,
709
+ :comments, TableRows.ptr,
689
710
  :array, :pointer,
690
711
  :merged_ranges, MergedRanges.ptr,
691
- :selections, Selections.ptr,
712
+ #:selections, Selections.ptr,
692
713
  :data_validations, :pointer, # TODO add real definition for lxw_data_validations
714
+ :conditional_formats, :pointer,
715
+ :image_props, :pointer,
693
716
  :image_data, ImageData.ptr,
694
717
  :chart_data, ChartData.ptr,
718
+ :drawing_rel_ids, :pointer,
719
+ :vml_drawing_rel_ids, :pointer,
720
+ :comment_objs, :pointer,
721
+ :header_image_objs, :pointer,
722
+ :button_objs, :pointer,
723
+ :table_objs, :pointer,
724
+ :table_count, :uint16,
725
+
695
726
  :dim_rowmin, :uint32,
696
727
  :dim_rowmax, :uint32,
697
728
  :dim_colmin, :uint16,
698
729
  :dim_colmax, :uint16,
730
+
699
731
  :sst, Sst.ptr,
700
732
  :name, :string,
701
733
  :quoted_name, :string,
702
734
  :tmpdir, :pointer,
703
- :index, :uint32,
704
- :active, :uint8,
705
- :selected, :uint8,
706
- :hidden, :uint8,
735
+
736
+ :index, :uint16,
737
+ :active, :uchar,
738
+ :selected, :uchar,
739
+ :hidden, :uchar,
707
740
  :active_sheet, :pointer,
708
741
  :first_sheet, :pointer,
709
- :is_chartsheet, :uint8,
742
+ :is_chartsheet, :uchar,
743
+
710
744
  :col_options, :pointer,
711
745
  :col_options_max, :uint16,
712
746
  :col_sizes, :pointer,
@@ -717,6 +751,7 @@ module Libxlsxwriter
717
751
  :row_size_changed, :uint8,
718
752
  :optimize, :uint8,
719
753
  :optimize_row, :pointer,
754
+
720
755
  :fit_height, :uint16,
721
756
  :fit_width, :uint16,
722
757
  :horizontal_dpi, :uint16,
@@ -726,6 +761,7 @@ module Libxlsxwriter
726
761
  :rel_count, :uint16,
727
762
  :vertical_dpi, :uint16,
728
763
  :zoom, :uint16,
764
+
729
765
  :filter_on, :uint8,
730
766
  :fit_page, :uint8,
731
767
  :hcenter, :uint8,
@@ -747,8 +783,12 @@ module Libxlsxwriter
747
783
  :show_zeros, :uint8,
748
784
  :vcenter, :uint8,
749
785
  :zoom_scale_normal, :uint8,
786
+ :black_white, :uint8,
750
787
  :num_validations, :uint8,
788
+ :has_dynamic_arrays, :uint8,
789
+
751
790
  :vba_codename, :pointer,
791
+ :num_buttons, :uint16,
752
792
  :tab_color, :int,
753
793
  :margin_left, :double,
754
794
  :margin_right, :double,
@@ -756,30 +796,44 @@ module Libxlsxwriter
756
796
  :margin_bottom, :double,
757
797
  :margin_header, :double,
758
798
  :margin_footer, :double,
799
+
759
800
  :default_row_height, :double,
760
801
  :default_row_pixels, :uint,
761
802
  :default_col_pixels, :uint,
762
- :default_row_zeroed, :uchar,
803
+ :default_row_zeroed, :uint8,
763
804
  :default_row_set, :uint8,
805
+ :outline_row_level, :uint8,
806
+ :outline_col_level, :uint8,
807
+
764
808
  :header_footer_changed, :uint8,
765
- :header, [:char, 255],
766
- :footer, [:char, 255],
809
+ :header, :pointer,
810
+ :footer, :pointer,
767
811
  :repeat_rows, RepeatRows.by_value,
768
812
  :repeat_cols, RepeatCols.by_value,
769
813
  :print_area, PrintArea.by_value,
770
814
  :autofilter, Autofilter.by_value,
815
+
771
816
  :merged_range_count, :uint16,
817
+ :max_url_length, :uint16,
818
+
772
819
  :hbreaks, :pointer,
773
820
  :vbreaks, :pointer,
774
821
  :hbreaks_count, :uint16,
775
822
  :vbreaks_count, :uint16,
823
+
824
+ :drawing_rel_id, :uint,
825
+ :vml_drawing_rel_id, :uint,
826
+
776
827
  :external_hyperlinks, :pointer,
777
828
  :external_drawing_links, :pointer,
778
829
  :drawing_links, :pointer,
830
+ :vml_drawing_links, :pointer,
831
+ :external_table_links, :pointer,
832
+
779
833
  :panes, Panes.by_value,
780
- :protection, Protection.by_value,
781
- :drawing, Drawing.ptr,
782
- :list_pointers, WorksheetListPointers.by_value
834
+ :protection, Protection.by_value
835
+ # :drawing, Drawing.ptr,
836
+ # :list_pointers, WorksheetListPointers.by_value
783
837
  end
784
838
 
785
839
  # = Fields:
@@ -990,6 +1044,18 @@ module Libxlsxwriter
990
1044
  # @scope class
991
1045
  attach_function :worksheet_write_string, :worksheet_write_string, [Worksheet, :uint32, :ushort, :string, Format], :error
992
1046
 
1047
+ attach_function :worksheet_write_comment, :worksheet_write_comment, [Worksheet, :uint32, :ushort, :string], :error
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
+
993
1059
  # @method worksheet_write_formula(worksheet, row, col, formula, format)
994
1060
  # @param [Worksheet] worksheet
995
1061
  # @param [Integer] row
@@ -1514,6 +1580,8 @@ module Libxlsxwriter
1514
1580
  # @scope class
1515
1581
  attach_function :worksheet_find_cell, :lxw_worksheet_find_cell, [Row, :ushort], Cell
1516
1582
 
1583
+ attach_function :worksheet_add_table, :worksheet_add_table, [Worksheet, :uint, :ushort, :uint, :ushort, :pointer], :error
1584
+
1517
1585
  # = Fields:
1518
1586
  # :rbe_left ::
1519
1587
  # (FFI::Pointer(*WorksheetName))