fast_excel 0.4.0 → 0.5.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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +28 -0
  3. data/.gitignore +2 -0
  4. data/CHANGELOG.md +18 -0
  5. data/Gemfile +10 -9
  6. data/Makefile +28 -1
  7. data/README.md +2 -2
  8. data/examples/example.rb +2 -0
  9. data/examples/example_date_time.rb +38 -0
  10. data/examples/example_filters.rb +2 -2
  11. data/fast_excel.gemspec +2 -2
  12. data/lib/fast_excel/binding/format.rb +17 -0
  13. data/lib/fast_excel/binding/workbook.rb +42 -20
  14. data/lib/fast_excel/binding/worksheet.rb +57 -13
  15. data/lib/fast_excel/binding.rb +12 -15
  16. data/lib/fast_excel.rb +38 -26
  17. data/libxlsxwriter/.github/FUNDING.yml +1 -0
  18. data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
  19. data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
  20. data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
  21. data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
  22. data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
  23. data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
  24. data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
  25. data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
  26. data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
  27. data/libxlsxwriter/.gitignore +16 -1
  28. data/libxlsxwriter/.indent.pro +24 -0
  29. data/libxlsxwriter/CMakeLists.txt +156 -56
  30. data/libxlsxwriter/CONTRIBUTING.md +2 -2
  31. data/libxlsxwriter/Changes.txt +344 -2
  32. data/libxlsxwriter/LICENSE.txt +66 -8
  33. data/libxlsxwriter/Makefile +151 -54
  34. data/libxlsxwriter/Package.swift +42 -0
  35. data/libxlsxwriter/Readme.md +4 -2
  36. data/libxlsxwriter/build.zig +324 -0
  37. data/libxlsxwriter/build.zig.zon +11 -0
  38. data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
  39. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
  40. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  41. data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
  42. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
  43. data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  44. data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
  45. data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
  46. data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  47. data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  48. data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
  49. data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
  50. data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  51. data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
  52. data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
  53. data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  54. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  55. data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
  56. data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
  57. data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  58. data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
  59. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
  60. data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
  61. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
  62. data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
  63. data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  64. data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
  65. data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
  66. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
  67. data/libxlsxwriter/include/xlsxwriter.h +4 -2
  68. data/libxlsxwriter/libxlsxwriter.podspec +8 -5
  69. data/libxlsxwriter/src/Makefile +58 -21
  70. data/libxlsxwriter/src/app.c +5 -2
  71. data/libxlsxwriter/src/chart.c +396 -81
  72. data/libxlsxwriter/src/chartsheet.c +22 -22
  73. data/libxlsxwriter/src/comment.c +443 -0
  74. data/libxlsxwriter/src/content_types.c +40 -1
  75. data/libxlsxwriter/src/core.c +2 -2
  76. data/libxlsxwriter/src/custom.c +1 -1
  77. data/libxlsxwriter/src/drawing.c +160 -40
  78. data/libxlsxwriter/src/format.c +109 -25
  79. data/libxlsxwriter/src/hash_table.c +1 -1
  80. data/libxlsxwriter/src/metadata.c +283 -0
  81. data/libxlsxwriter/src/packager.c +794 -94
  82. data/libxlsxwriter/src/relationships.c +1 -1
  83. data/libxlsxwriter/src/shared_strings.c +2 -4
  84. data/libxlsxwriter/src/styles.c +353 -58
  85. data/libxlsxwriter/src/table.c +304 -0
  86. data/libxlsxwriter/src/theme.c +1 -1
  87. data/libxlsxwriter/src/utility.c +143 -43
  88. data/libxlsxwriter/src/vml.c +1062 -0
  89. data/libxlsxwriter/src/workbook.c +567 -77
  90. data/libxlsxwriter/src/worksheet.c +6668 -1462
  91. data/libxlsxwriter/src/xmlwriter.c +95 -5
  92. data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
  93. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
  94. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
  95. data/libxlsxwriter/third_party/md5/Makefile +42 -0
  96. data/libxlsxwriter/third_party/md5/md5.c +291 -0
  97. data/libxlsxwriter/third_party/md5/md5.h +45 -0
  98. data/libxlsxwriter/third_party/minizip/Makefile +3 -8
  99. data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
  100. data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
  101. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  102. data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
  103. data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
  104. data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
  105. data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
  106. data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
  107. data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
  108. data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
  109. data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
  110. data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
  111. data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
  112. data/libxlsxwriter/third_party/minizip/zip.c +165 -218
  113. data/libxlsxwriter/third_party/minizip/zip.h +164 -154
  114. data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
  115. data/libxlsxwriter/version.txt +1 -1
  116. data/test/auto_width_test.rb +20 -0
  117. data/test/default_format_test.rb +1 -1
  118. data/test/validations_test.rb +13 -2
  119. data/test/worksheet_test.rb +6 -1
  120. metadata +34 -11
  121. data/.travis.yml +0 -51
  122. data/Gemfile.lock +0 -79
  123. data/appveyor.yml +0 -25
  124. data/libxlsxwriter/.travis.yml +0 -37
  125. data/test/text_width_test.rb +0 -80
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7acf199afdfc96f315ac6487ec4c72a25f6624388d2139821ca1a14aaac9a5e
4
- data.tar.gz: 071322b38f573d7774a26025c1f866203a9e1b0b0bca143fdbedfc81af274fd0
3
+ metadata.gz: 792a2afe9492aeeaba9fbb65da941d2b604a2fd14bf934b17662fdf05281ac32
4
+ data.tar.gz: 11795006b99d4fc9403fd3f85ab6babff417b1ed49341a2081073852063d2a71
5
5
  SHA512:
6
- metadata.gz: f0f4583c984b84dd9e4960771ab1d094ade8fc271d66e7052b3bb249a870e5fec0302a898652e020cec61d17ceaa2babf73cf84a3a2556c05f83e1b8cf82182b
7
- data.tar.gz: 162dee5762798ce6ecac84bcc0cc10f38f03f46d3fd4eb490c039dc2e67ede50294f7bfd744be72e58dedacc41c3aad76997a1642ba3e379d8c33d8edca938d0
6
+ metadata.gz: 7215d937426efb2580ba947c727a60a519fb411a5504eb58162a1646057bd191812eae00394ac9c915a9f7f53a6acf6cfff66e4d773a8ac579bb3494164c3292
7
+ data.tar.gz: 9f381f209a7d4f7c22a0994ed241b2be0a67d994c400f7867529fa1fa95fbc6326189a9dc53588f0bfbc376933ffab6fee4eaee37f7ac57d6a4f68a66295c8cc
@@ -0,0 +1,28 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ os: [ubuntu-latest, macos-latest, windows-latest]
11
+ ruby: [2.7, '3.0', 3.1, 3.2, 3.3]
12
+
13
+ runs-on: ${{ matrix.os }}
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+
21
+ - run: bundle config set --local without 'benchmarks'
22
+ - run: bundle install
23
+ - run: make
24
+ - run: make install
25
+
26
+ - run: rake test
27
+ - run: rake examples
28
+ - run: gem build fast_excel.gemspec
data/.gitignore CHANGED
@@ -18,3 +18,5 @@ libxlsxwriter/test
18
18
  ext/fast_excel/text_width_ext.o
19
19
  ext/fast_excel/Makefile
20
20
  ext/fast_excel/text_width_ext.bundle
21
+ Gemfile.lock
22
+ lib/libxlsxwriter.dylib
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ #### Version 0.5.0 - 02 jan 2024
2
+
3
+ * Support ruby 3.3
4
+ * Sync latest libxlsxwriter
5
+ * Add support for writing cell comments
6
+ * Add more examples
7
+ * Fix compilation of minizip on NixOS (Thanks to @Mange)
8
+ * On close set empty columns to default width (Thanks to @steffansluis)
9
+
10
+ #### Version 0.4.1 - 13 jan 2023
11
+
12
+ * Support ruby 3.2
13
+ * Improve library loading (Thanks to @sly7-7 and @BrianHawley)
14
+ * Ensure Time.zone is not nil (Thanks to @ksuh90)
15
+ * Get utc_offset from current value if possible (Thanks to @KevinSchiffmann)
16
+ * Validate worksheet name using Libxlsxwriter (Thanks to @datbth)
17
+ * Fix readme typo (Thanks to @sw4d)
18
+
1
19
  #### Version 0.4.0 - 14 feb 2021
2
20
 
3
21
  * Support ruby 3.0
data/Gemfile CHANGED
@@ -1,18 +1,19 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'ffi'
4
- gem 'ffi_gen', require: false
3
+ gemspec
5
4
 
6
5
  gem 'rake'
7
6
 
8
- gem 'roo', '2.8.3', git: 'https://github.com/roo-rb/roo.git', tag: 'v2.8.3'
7
+ gem 'roo'
9
8
 
10
9
  gem 'minitest'
11
10
  gem 'minitest-reporters'
12
11
 
13
- # For benchmakrs
14
- gem 'axlsx', git: 'https://github.com/randym/axlsx.git'
15
- gem 'write_xlsx'
16
- gem 'xlsxtream'
17
- gem 'benchmark-ips'
18
- gem 'process_memory', git: 'https://github.com/paxa/process_memory', platforms: :ruby
12
+
13
+ group :benchmarks do
14
+ gem 'axlsx', git: 'https://github.com/randym/axlsx.git'
15
+ gem 'write_xlsx'
16
+ gem 'xlsxtream'
17
+ gem 'benchmark-ips'
18
+ gem 'process_memory', git: 'https://github.com/paxa/process_memory', platforms: :ruby
19
+ end
data/Makefile CHANGED
@@ -3,12 +3,39 @@ ifdef V
3
3
  Q=
4
4
  endif
5
5
 
6
+ UNAME := $(shell uname)
7
+
8
+ LIBXLSXWRITER_SO = libxlsxwriter.so
9
+
10
+ ifeq ($(UNAME), Darwin)
11
+ LIBXLSXWRITER_SO = libxlsxwriter.dylib
12
+ endif
13
+
14
+ # Check for MinGW/MinGW64/Cygwin environments.
15
+ ifneq (,$(findstring MINGW, $(UNAME)))
16
+ MING_LIKE = y
17
+ endif
18
+ ifneq (,$(findstring MSYS, $(UNAME)))
19
+ MING_LIKE = y
20
+ endif
21
+ ifneq (,$(findstring CYGWIN, $(UNAME)))
22
+ MING_LIKE = y
23
+ endif
24
+
25
+ ifdef MING_LIKE
26
+ LIBXLSXWRITER_SO = libxlsxwriter.dll
27
+ endif
28
+
6
29
  # with xcode better to use cmake
7
30
  UNAME_S := $(shell uname -s)
8
31
  ifeq ($(UNAME_S),"Darwin")
9
32
  USE_CMAKE := $(shell command -v cmake 2> /dev/null)
10
33
  endif
11
34
 
35
+ ifndef ($(sitearchdir))
36
+ sitearchdir = './lib'
37
+ endif
38
+
12
39
  all :
13
40
  # @echo "Compiling ext/text_width ..."
14
41
  # rake compile
@@ -24,4 +51,4 @@ clean :
24
51
  $(Q)$(MAKE) clean -C libxlsxwriter
25
52
 
26
53
  install :
27
- @echo "Nothing to install"
54
+ $(Q)cp libxlsxwriter/lib/$(LIBXLSXWRITER_SO) $(sitearchdir)
data/README.md CHANGED
@@ -55,7 +55,7 @@ workbook = FastExcel.open # creates tmp file
55
55
  send_data(workbook.read_string, filename: "table.xlsx") # read tmp file and delete it
56
56
  ```
57
57
 
58
- Also can use `workbook.remove_tmp_file` to delete tmp file manually
58
+ Also can use `workbook.remove_tmp_folder` to delete tmp file manually
59
59
 
60
60
 
61
61
  **Constant memory mode**: saves each row to disk, good for really big files but can not change previous lines that already saved
@@ -118,7 +118,7 @@ worksheet.write_url(0, 2, "https://github.com/Paxa/fast_excel", url_format)
118
118
 
119
119
  ### Data Formatting
120
120
  ```ruby
121
- format = worksheet.add_format(
121
+ format = workbook.add_format(
122
122
  bold: true,
123
123
  italic: true,
124
124
  font_outline: true,
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"
@@ -12,8 +12,8 @@ workbook.default_format.set(
12
12
 
13
13
  worksheet = workbook.add_worksheet("Payments Report")
14
14
 
15
- p worksheet[:filter_on]
16
- FastExcel.print_ffi_obj(worksheet)
15
+ # p worksheet[:filter_on]
16
+ # FastExcel.print_ffi_obj(worksheet)
17
17
 
18
18
  bold = workbook.bold_format
19
19
  worksheet.set_column(0, 0, FastExcel::DEF_COL_WIDTH, bold)
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.0"
3
+ s.version = "0.5.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 = []
@@ -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
 
@@ -7,7 +7,9 @@ module Libxlsxwriter
7
7
  class WorkbookOptions < FFI::Struct
8
8
  layout :constant_memory, :uchar,
9
9
  :tmpdir, :string,
10
- :use_zip64, :uchar
10
+ :use_zip64, :uchar,
11
+ :output_buffer, :pointer,
12
+ :output_buffer_size, :pointer
11
13
  end
12
14
 
13
15
  # = Fields:
@@ -147,7 +149,7 @@ module Libxlsxwriter
147
149
  # @param [String] sheetname
148
150
  # @return [Symbol from _enum_error_]
149
151
  def validate_worksheet_name(sheetname)
150
- Libxlsxwriter.workbook_validate_worksheet_name(self, sheetname)
152
+ Libxlsxwriter.workbook_validate_sheet_name(self, sheetname)
151
153
  end
152
154
 
153
155
  # @return [nil]
@@ -174,6 +176,9 @@ module Libxlsxwriter
174
176
  :chartsheets, :pointer,
175
177
  :worksheet_names, WorksheetNames.ptr,
176
178
  :chartsheet_names, :pointer,
179
+ :image_md5s, :pointer,
180
+ :header_image_md5s, :pointer,
181
+ :background_md5s, :pointer,
177
182
  :charts, Charts.ptr,
178
183
  :ordered_charts, Charts.ptr,
179
184
  :formats, Formats.ptr,
@@ -181,26 +186,43 @@ module Libxlsxwriter
181
186
  :sst, Sst.ptr,
182
187
  :properties, DocProperties.ptr,
183
188
  :custom_properties, CustomProperties.ptr,
184
- :filename, :pointer,
189
+ :filename, :string,
185
190
  :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,
191
+
192
+ :num_sheets, :uint16,
193
+ :num_worksheets, :uint16,
194
+ :num_chartsheets, :uint16,
195
+ :first_sheet, :uint16,
196
+ :active_sheet, :uint16,
197
+ :num_xf_formats, :uint16,
198
+ :num_dxf_formats, :uint16,
192
199
  :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,
200
+ :drawing_count, :uint16,
201
+ :comment_count, :uint16,
202
+
203
+ :font_count, :uint16,
204
+ :border_count, :uint16,
205
+ :fill_count, :uint16,
206
+ :optimize, :uchar,
207
+ :max_url_length, :uint16,
208
+ :read_only, :uchar,
209
+
210
+ :has_png, :uchar,
199
211
  :has_jpeg, :uchar,
200
- :has_bmp, :uchar,
212
+ :has_bmp, :uchar,
213
+ :has_gif, :uchar,
214
+ :has_vml, :uchar,
215
+ :has_comments, :uchar,
216
+ :has_metadata, :uchar,
217
+
201
218
  :used_xf_formats, HashTable.ptr,
202
- :vba_project, :pointer,
203
- :vba_codename, :pointer
219
+ :used_dxf_formats, HashTable.ptr,
220
+
221
+ :vba_project, :string,
222
+ :vba_project_signature, :string,
223
+ :vba_codename, :string,
224
+
225
+ :default_url_format, :pointer
204
226
  end
205
227
 
206
228
  attach_function :workbook_default_format, :workbook_default_format, [Workbook], Format
@@ -319,12 +341,12 @@ module Libxlsxwriter
319
341
  # @scope class
320
342
  attach_function :workbook_get_worksheet_by_name, :workbook_get_worksheet_by_name, [Workbook, :string], Worksheet
321
343
 
322
- # @method workbook_validate_worksheet_name(workbook, sheetname)
344
+ # @method workbook_validate_sheet_name(workbook, sheetname)
323
345
  # @param [Workbook] workbook
324
346
  # @param [String] sheetname
325
347
  # @return [Symbol from _enum_error_]
326
348
  # @scope class
327
- attach_function :workbook_validate_worksheet_name, :workbook_validate_worksheet_name, [Workbook, :string], :error
349
+ attach_function :workbook_validate_sheet_name, :workbook_validate_sheet_name, [Workbook, :string], :error
328
350
 
329
351
  # @method workbook_free(workbook)
330
352
  # @param [Workbook] workbook
@@ -209,7 +209,11 @@ 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)
214
+ Libxlsxwriter.worksheet_write_comment(self, row, col, string)
215
+ end
216
+
213
217
  # @param [Integer] row
214
218
  # @param [Integer] col
215
219
  # @param [String] formula
@@ -684,29 +688,45 @@ module Libxlsxwriter
684
688
  include WorksheetWrappers
685
689
  layout :file, :pointer,
686
690
  :optimize_tmpfile, :pointer,
691
+ :optimize_buffer, :pointer,
692
+ :optimize_buffer_size, :size_t,
687
693
  :table, TableRows.ptr,
688
694
  :hyperlinks, TableRows.ptr,
695
+ :comments, TableRows.ptr,
689
696
  :array, :pointer,
690
697
  :merged_ranges, MergedRanges.ptr,
691
- :selections, Selections.ptr,
698
+ #:selections, Selections.ptr,
692
699
  :data_validations, :pointer, # TODO add real definition for lxw_data_validations
700
+ :conditional_formats, :pointer,
701
+ :image_props, :pointer,
693
702
  :image_data, ImageData.ptr,
694
703
  :chart_data, ChartData.ptr,
704
+ :drawing_rel_ids, :pointer,
705
+ :vml_drawing_rel_ids, :pointer,
706
+ :comment_objs, :pointer,
707
+ :header_image_objs, :pointer,
708
+ :button_objs, :pointer,
709
+ :table_objs, :pointer,
710
+ :table_count, :uint16,
711
+
695
712
  :dim_rowmin, :uint32,
696
713
  :dim_rowmax, :uint32,
697
714
  :dim_colmin, :uint16,
698
715
  :dim_colmax, :uint16,
716
+
699
717
  :sst, Sst.ptr,
700
718
  :name, :string,
701
719
  :quoted_name, :string,
702
720
  :tmpdir, :pointer,
703
- :index, :uint32,
704
- :active, :uint8,
705
- :selected, :uint8,
706
- :hidden, :uint8,
721
+
722
+ :index, :uint16,
723
+ :active, :uchar,
724
+ :selected, :uchar,
725
+ :hidden, :uchar,
707
726
  :active_sheet, :pointer,
708
727
  :first_sheet, :pointer,
709
- :is_chartsheet, :uint8,
728
+ :is_chartsheet, :uchar,
729
+
710
730
  :col_options, :pointer,
711
731
  :col_options_max, :uint16,
712
732
  :col_sizes, :pointer,
@@ -717,6 +737,7 @@ module Libxlsxwriter
717
737
  :row_size_changed, :uint8,
718
738
  :optimize, :uint8,
719
739
  :optimize_row, :pointer,
740
+
720
741
  :fit_height, :uint16,
721
742
  :fit_width, :uint16,
722
743
  :horizontal_dpi, :uint16,
@@ -726,6 +747,7 @@ module Libxlsxwriter
726
747
  :rel_count, :uint16,
727
748
  :vertical_dpi, :uint16,
728
749
  :zoom, :uint16,
750
+
729
751
  :filter_on, :uint8,
730
752
  :fit_page, :uint8,
731
753
  :hcenter, :uint8,
@@ -747,8 +769,12 @@ module Libxlsxwriter
747
769
  :show_zeros, :uint8,
748
770
  :vcenter, :uint8,
749
771
  :zoom_scale_normal, :uint8,
772
+ :black_white, :uint8,
750
773
  :num_validations, :uint8,
774
+ :has_dynamic_arrays, :uint8,
775
+
751
776
  :vba_codename, :pointer,
777
+ :num_buttons, :uint16,
752
778
  :tab_color, :int,
753
779
  :margin_left, :double,
754
780
  :margin_right, :double,
@@ -756,30 +782,44 @@ module Libxlsxwriter
756
782
  :margin_bottom, :double,
757
783
  :margin_header, :double,
758
784
  :margin_footer, :double,
785
+
759
786
  :default_row_height, :double,
760
787
  :default_row_pixels, :uint,
761
788
  :default_col_pixels, :uint,
762
- :default_row_zeroed, :uchar,
789
+ :default_row_zeroed, :uint8,
763
790
  :default_row_set, :uint8,
791
+ :outline_row_level, :uint8,
792
+ :outline_col_level, :uint8,
793
+
764
794
  :header_footer_changed, :uint8,
765
- :header, [:char, 255],
766
- :footer, [:char, 255],
795
+ :header, :pointer,
796
+ :footer, :pointer,
767
797
  :repeat_rows, RepeatRows.by_value,
768
798
  :repeat_cols, RepeatCols.by_value,
769
799
  :print_area, PrintArea.by_value,
770
800
  :autofilter, Autofilter.by_value,
801
+
771
802
  :merged_range_count, :uint16,
803
+ :max_url_length, :uint16,
804
+
772
805
  :hbreaks, :pointer,
773
806
  :vbreaks, :pointer,
774
807
  :hbreaks_count, :uint16,
775
808
  :vbreaks_count, :uint16,
809
+
810
+ :drawing_rel_id, :uint,
811
+ :vml_drawing_rel_id, :uint,
812
+
776
813
  :external_hyperlinks, :pointer,
777
814
  :external_drawing_links, :pointer,
778
815
  :drawing_links, :pointer,
816
+ :vml_drawing_links, :pointer,
817
+ :external_table_links, :pointer,
818
+
779
819
  :panes, Panes.by_value,
780
- :protection, Protection.by_value,
781
- :drawing, Drawing.ptr,
782
- :list_pointers, WorksheetListPointers.by_value
820
+ :protection, Protection.by_value
821
+ # :drawing, Drawing.ptr,
822
+ # :list_pointers, WorksheetListPointers.by_value
783
823
  end
784
824
 
785
825
  # = Fields:
@@ -990,6 +1030,8 @@ module Libxlsxwriter
990
1030
  # @scope class
991
1031
  attach_function :worksheet_write_string, :worksheet_write_string, [Worksheet, :uint32, :ushort, :string, Format], :error
992
1032
 
1033
+ attach_function :worksheet_write_comment, :worksheet_write_comment, [Worksheet, :uint32, :ushort, :string], :error
1034
+
993
1035
  # @method worksheet_write_formula(worksheet, row, col, formula, format)
994
1036
  # @param [Worksheet] worksheet
995
1037
  # @param [Integer] row
@@ -1514,6 +1556,8 @@ module Libxlsxwriter
1514
1556
  # @scope class
1515
1557
  attach_function :worksheet_find_cell, :lxw_worksheet_find_cell, [Row, :ushort], Cell
1516
1558
 
1559
+ attach_function :worksheet_add_table, :worksheet_add_table, [Worksheet, :uint, :ushort, :uint, :ushort, :pointer], :error
1560
+
1517
1561
  # = Fields:
1518
1562
  # :rbe_left ::
1519
1563
  # (FFI::Pointer(*WorksheetName))
@@ -5,15 +5,12 @@ require 'ffi'
5
5
  module Libxlsxwriter
6
6
  extend FFI::Library
7
7
 
8
- LIB_FILENAME = if RUBY_PLATFORM =~ /darwin/
9
- "libxlsxwriter.dylib"
10
- elsif ['x64-mingw32', 'i386-mingw32'].include? RUBY_PLATFORM
11
- "libxlsxwriter.dll"
12
- else
13
- "libxlsxwriter.so"
14
- end
8
+ LIB_FILENAME = "libxlsxwriter.#{FFI::Platform::LIBSUFFIX}".freeze
9
+
10
+ libs = [File.expand_path("../../#{LIB_FILENAME}", __FILE__)]
11
+ libs.unshift(File.join(Gem.loaded_specs['fast_excel'].extension_dir, LIB_FILENAME)) if Gem.loaded_specs['fast_excel']
15
12
 
16
- ffi_lib File.expand_path("./../../../libxlsxwriter/lib/#{LIB_FILENAME}", __FILE__)
13
+ ffi_lib(libs)
17
14
 
18
15
  def self.attach_function(name, *_)
19
16
  begin; super; rescue FFI::NotFoundError => e
@@ -330,13 +327,13 @@ module Libxlsxwriter
330
327
  :error_zip_internal_error, 8,
331
328
  :error_zip_file_add, 9,
332
329
  :error_zip_close, 10,
333
- :error_null_parameter_ignored, 11,
334
- :error_parameter_validation, 12,
335
- :error_sheetname_length_exceeded, 13,
336
- :error_invalid_sheetname_character, 14,
337
- :error_sheetname_start_end_apostrophe, 15,
338
- :error_sheetname_already_used, 16,
339
- :error_sheetname_reserved, 17,
330
+ :error_feature_not_supported, 11,
331
+ :error_null_parameter_ignored, 12,
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,
340
337
  :error_32_string_length_exceeded, 18,
341
338
  :error_128_string_length_exceeded, 19,
342
339
  :error_255_string_length_exceeded, 20,