fast_excel 0.4.1 → 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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -7
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +1 -1
  5. data/examples/example.rb +2 -0
  6. data/examples/example_date_time.rb +38 -0
  7. data/fast_excel.gemspec +2 -2
  8. data/lib/fast_excel/binding/format.rb +17 -0
  9. data/lib/fast_excel/binding/workbook.rb +39 -17
  10. data/lib/fast_excel/binding/worksheet.rb +57 -13
  11. data/lib/fast_excel/binding.rb +7 -7
  12. data/lib/fast_excel.rb +27 -20
  13. data/libxlsxwriter/.github/FUNDING.yml +1 -0
  14. data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
  15. data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
  16. data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
  17. data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
  18. data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
  19. data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
  20. data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
  21. data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
  22. data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
  23. data/libxlsxwriter/.gitignore +16 -1
  24. data/libxlsxwriter/.indent.pro +24 -0
  25. data/libxlsxwriter/CMakeLists.txt +156 -56
  26. data/libxlsxwriter/CONTRIBUTING.md +2 -2
  27. data/libxlsxwriter/Changes.txt +344 -2
  28. data/libxlsxwriter/LICENSE.txt +66 -8
  29. data/libxlsxwriter/Makefile +151 -54
  30. data/libxlsxwriter/Package.swift +42 -0
  31. data/libxlsxwriter/Readme.md +4 -2
  32. data/libxlsxwriter/build.zig +324 -0
  33. data/libxlsxwriter/build.zig.zon +11 -0
  34. data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
  35. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
  36. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  37. data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
  38. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
  39. data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  40. data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
  41. data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
  42. data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  43. data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  44. data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
  45. data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
  46. data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  47. data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
  48. data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
  49. data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  50. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  51. data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
  52. data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
  53. data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  54. data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
  55. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
  56. data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
  57. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
  58. data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
  59. data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  60. data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
  61. data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
  62. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
  63. data/libxlsxwriter/include/xlsxwriter.h +4 -2
  64. data/libxlsxwriter/libxlsxwriter.podspec +8 -5
  65. data/libxlsxwriter/src/Makefile +58 -21
  66. data/libxlsxwriter/src/app.c +5 -2
  67. data/libxlsxwriter/src/chart.c +396 -81
  68. data/libxlsxwriter/src/chartsheet.c +22 -22
  69. data/libxlsxwriter/src/comment.c +443 -0
  70. data/libxlsxwriter/src/content_types.c +40 -1
  71. data/libxlsxwriter/src/core.c +2 -2
  72. data/libxlsxwriter/src/custom.c +1 -1
  73. data/libxlsxwriter/src/drawing.c +160 -40
  74. data/libxlsxwriter/src/format.c +109 -25
  75. data/libxlsxwriter/src/hash_table.c +1 -1
  76. data/libxlsxwriter/src/metadata.c +283 -0
  77. data/libxlsxwriter/src/packager.c +794 -94
  78. data/libxlsxwriter/src/relationships.c +1 -1
  79. data/libxlsxwriter/src/shared_strings.c +2 -4
  80. data/libxlsxwriter/src/styles.c +353 -58
  81. data/libxlsxwriter/src/table.c +304 -0
  82. data/libxlsxwriter/src/theme.c +1 -1
  83. data/libxlsxwriter/src/utility.c +143 -43
  84. data/libxlsxwriter/src/vml.c +1062 -0
  85. data/libxlsxwriter/src/workbook.c +567 -77
  86. data/libxlsxwriter/src/worksheet.c +6668 -1462
  87. data/libxlsxwriter/src/xmlwriter.c +95 -5
  88. data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
  89. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
  90. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
  91. data/libxlsxwriter/third_party/md5/Makefile +42 -0
  92. data/libxlsxwriter/third_party/md5/md5.c +291 -0
  93. data/libxlsxwriter/third_party/md5/md5.h +45 -0
  94. data/libxlsxwriter/third_party/minizip/Makefile +3 -8
  95. data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
  96. data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
  97. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  98. data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
  99. data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
  100. data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
  101. data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
  102. data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
  103. data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
  104. data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
  105. data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
  106. data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
  107. data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
  108. data/libxlsxwriter/third_party/minizip/zip.c +165 -218
  109. data/libxlsxwriter/third_party/minizip/zip.h +164 -154
  110. data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
  111. data/libxlsxwriter/version.txt +1 -1
  112. data/test/auto_width_test.rb +20 -0
  113. data/test/default_format_test.rb +1 -1
  114. data/test/validations_test.rb +3 -3
  115. data/test/worksheet_test.rb +6 -1
  116. metadata +33 -7
  117. data/libxlsxwriter/.travis.yml +0 -37
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Makefile for libxlsxwriter library.
4
4
  #
5
- # Copyright 2014-2019, John McNamara, jmcnamara@cpan.org
5
+ # Copyright 2014-2022, John McNamara, jmcnamara@cpan.org
6
6
  #
7
7
 
8
8
  # Keep the output quiet by default.
@@ -11,45 +11,86 @@ ifdef V
11
11
  Q=
12
12
  endif
13
13
 
14
- INSTALL_DIR ?= /usr/local
14
+ DESTDIR ?=
15
+ PREFIX ?= /usr/local
15
16
 
16
17
  PYTEST ?= py.test
18
+ PYTESTFILES ?= test
17
19
 
18
- .PHONY: docs tags examples
20
+ VERSION = $(shell sed -n -e 's/.*LXW_VERSION \"\(.*\)\"/\1/p' include/xlsxwriter.h)
21
+ SOVERSION = $(shell sed -n -e 's/.*LXW_SOVERSION \"\(.*\)\"/\1/p' include/xlsxwriter.h)
19
22
 
20
- # Build the libs.
21
- all :
23
+ .PHONY: docs tags examples third_party
24
+
25
+ # Build libxlsxwriter.
26
+ all : third_party
27
+ $(Q)$(MAKE) -C src
28
+
29
+ # Build the third party libs.
30
+ third_party :
22
31
  ifndef USE_SYSTEM_MINIZIP
23
32
  $(Q)$(MAKE) -C third_party/minizip
24
33
  endif
25
34
  ifndef USE_STANDARD_TMPFILE
26
35
  $(Q)$(MAKE) -C third_party/tmpfileplus
27
36
  endif
28
- $(Q)$(MAKE) -C src
37
+ ifndef USE_NO_MD5
38
+ ifndef USE_OPENSSL_MD5
39
+ $(Q)$(MAKE) -C third_party/md5
40
+ endif
41
+ endif
42
+ ifdef USE_DTOA_LIBRARY
43
+ $(Q)$(MAKE) -C third_party/dtoa
44
+ endif
45
+
46
+ # Build a macOS universal binary.
47
+ universal_binary :
48
+ $(Q)$(MAKE) clean
49
+ $(Q)TARGET_ARCH="-target x86_64-apple-macos10.12" $(MAKE) all
50
+ $(Q)mv lib/libxlsxwriter.a libxlsxwriter_x86_64.a
51
+ $(Q)mv lib/libxlsxwriter.$(SOVERSION).dylib libxlsxwriter_x86_64.dylib
52
+
53
+ $(Q)$(MAKE) clean
54
+ $(Q)TARGET_ARCH="-target arm64-apple-macos11" $(MAKE) all
55
+ $(Q)mv lib/libxlsxwriter.a lib/libxlsxwriter_arm64.a
56
+ $(Q)mv lib/libxlsxwriter.$(SOVERSION).dylib lib/libxlsxwriter_arm64.dylib
57
+ $(Q)mv libxlsxwriter_x86_64.a libxlsxwriter_x86_64.dylib lib
58
+
59
+ $(Q)lipo -create -output lib/libxlsxwriter.a lib/libxlsxwriter_x86_64.a lib/libxlsxwriter_arm64.a
60
+ $(Q)lipo -create -output lib/libxlsxwriter.$(SOVERSION).dylib lib/libxlsxwriter_x86_64.dylib lib/libxlsxwriter_arm64.dylib
61
+ $(Q)rm -f lib/libxlsxwriter_x86_64.* lib/libxlsxwriter_arm64.*
29
62
 
30
63
  # Build the example programs.
31
- examples :
64
+ examples : all
32
65
  $(Q)$(MAKE) -C examples
33
66
 
67
+ # Build the example programs with CPP for compatibility checking.
68
+ examples_cpp : all
69
+ $(Q)$(MAKE) -C examples CC=$(CXX)
70
+
34
71
  # Clean src and test directories.
35
72
  clean :
36
73
  $(Q)$(MAKE) clean -C src
37
- # $(Q)$(MAKE) clean -C test/unit
38
- # $(Q)$(MAKE) clean -C test/functional/src
39
- # $(Q)$(MAKE) clean -C examples
74
+ $(Q)$(MAKE) clean -C test/unit
75
+ $(Q)$(MAKE) clean -C test/functional/src
76
+ $(Q)$(MAKE) clean -C test/cpp
77
+ $(Q)$(MAKE) clean -C examples
40
78
  $(Q)rm -rf docs/html
41
79
  $(Q)rm -rf test/functional/__pycache__
42
80
  $(Q)rm -f test/functional/*.pyc
43
81
  $(Q)rm -f lib/*
44
- ifndef USE_STANDARD_TMPFILE
45
82
  $(Q)$(MAKE) clean -C third_party/minizip
46
- endif
47
- ifndef USE_STANDARD_TMPFILE
48
83
  $(Q)$(MAKE) clean -C third_party/tmpfileplus
49
- endif
84
+ $(Q)$(MAKE) clean -C third_party/md5
85
+ $(Q)$(MAKE) clean -C third_party/dtoa
86
+
87
+ # Clean src and lib dir only, as a precursor for static analysis.
88
+ clean_src :
89
+ $(Q)$(MAKE) clean -C src
90
+ $(Q)rm -f lib/*
50
91
 
51
92
  # Run the unit tests.
52
- test : all test_functional test_unit
93
+ test : all test_cpp test_unit test_functional
53
94
 
54
95
  # Test for C++ const correctness on APIs.
55
96
  test_const : all
@@ -60,20 +101,30 @@ test_const : all
60
101
  # Run the functional tests.
61
102
  test_functional : all
62
103
  $(Q)$(MAKE) -C test/functional/src
63
- $(Q)$(PYTEST) test/functional -v
104
+ $(Q)$(PYTEST) test/functional -v -k $(PYTESTFILES)
64
105
 
65
106
  # Run all tests.
66
- test_unit :
67
- @echo "Compiling unit tests ..."
68
- ifndef USE_SYSTEM_MINIZIP
69
- $(Q)$(MAKE) -C third_party/minizip
70
- endif
71
- ifndef USE_STANDARD_TMPFILE
72
- $(Q)$(MAKE) -C third_party/tmpfileplus
73
- endif
107
+ test_unit : all
74
108
  $(Q)$(MAKE) -C src test_lib
75
109
  $(Q)$(MAKE) -C test/unit test
76
110
 
111
+ # Test C++ compilation.
112
+ test_cpp : all
113
+ $(Q)$(MAKE) -C test/cpp
114
+
115
+ # Test Cmake. This test should really be done with Cmake in the cmake dir but
116
+ # this is a workaround for now.
117
+ test_cmake :
118
+ ifneq ($(findstring m32,$(CFLAGS)),m32)
119
+ $(Q)$(MAKE) -C src clean
120
+ $(Q)cd cmake; cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON; make clean; make; cp libxlsxwriter.a ../src/
121
+ $(Q)cmake/xlsxwriter_unit
122
+ $(Q)$(MAKE) -C test/functional/src
123
+ $(Q)$(PYTEST) test/functional -v -k $(PYTESTFILES)
124
+ else
125
+ @echo "Skipping Cmake tests on 32 bit target."
126
+ endif
127
+
77
128
  # Test the functional test exes with valgrind (in 64bit mode only).
78
129
  test_valgrind : all
79
130
  ifndef NO_VALGRIND
@@ -97,50 +148,95 @@ tags:
97
148
  doc: docs
98
149
  docs:
99
150
  $(Q)$(MAKE) -C docs
151
+ @echo "Docs built."
152
+
153
+ docs_doxygen_only:
154
+ $(Q)$(MAKE) -C docs docs_doxygen_only
100
155
 
101
- # Simple minded install.
156
+ docs_external:
157
+ $(Q)make -C ../libxlsxwriter.github.io release
158
+
159
+ # Simple install.
102
160
  install: all
103
- $(Q)mkdir -p $(INSTALL_DIR)/include
104
- $(Q)cp -R include/* $(INSTALL_DIR)/include
105
- $(Q)mkdir -p $(INSTALL_DIR)/lib
106
- $(Q)cp lib/* $(INSTALL_DIR)/lib
161
+ $(Q)mkdir -p $(DESTDIR)$(PREFIX)/include
162
+ $(Q)cp -R include/* $(DESTDIR)$(PREFIX)/include
163
+ $(Q)mkdir -p $(DESTDIR)$(PREFIX)/lib
164
+ $(Q)cp -R lib/* $(DESTDIR)$(PREFIX)/lib
165
+ $(Q)mkdir -p $(DESTDIR)$(PREFIX)/lib/pkgconfig
166
+ $(Q)sed -e 's|@PREFIX@|$(PREFIX)|g' -e 's|@VERSION@|$(VERSION)|g' dev/release/pkg-config.txt > $(DESTDIR)$(PREFIX)/lib/pkgconfig/xlsxwriter.pc
107
167
 
108
- # Simpler minded uninstall.
168
+ # Simpler uninstall.
109
169
  uninstall:
110
- $(Q)rm -rf $(INSTALL_DIR)/include/xlsxwriter*
111
- $(Q)rm $(INSTALL_DIR)/lib/libxlsxwriter.*
170
+ $(Q)rm -rf $(DESTDIR)$(PREFIX)/include/xlsxwriter*
171
+ $(Q)rm $(DESTDIR)$(PREFIX)/lib/libxlsxwriter.*
172
+ $(Q)rm $(DESTDIR)$(PREFIX)/lib/pkgconfig/xlsxwriter.pc
112
173
 
113
174
  # Strip the lib files.
114
175
  strip:
115
176
  $(Q)strip lib/*
116
177
 
117
178
  # Run a coverity static analysis.
118
- coverity:
119
- ifndef USE_SYSTEM_MINIZIP
120
- $(Q)$(MAKE) -C third_party/minizip
121
- endif
122
- ifndef USE_STANDARD_TMPFILE
123
- $(Q)$(MAKE) -C third_party/tmpfileplus
124
- endif
125
- $(Q)$(MAKE) -C src clean
126
- $(Q)rm -f lib/*
179
+ coverity: clean_src third_party
127
180
  $(Q)rm -rf cov-int
128
181
  $(Q)rm -f libxlsxwriter-coverity.tgz
129
- $(Q)../../cov-analysis-linux64-8.7.0/bin/cov-build --dir cov-int make -C src libxlsxwriter.a
182
+ $(Q)../../cov-analysis-linux64-2019.03/bin/cov-build --dir cov-int make -C src libxlsxwriter.a
130
183
  $(Q)tar -czf libxlsxwriter-coverity.tgz cov-int
131
184
  $(Q)$(MAKE) -C src clean
132
185
  $(Q)rm -f lib/*
133
186
 
134
- # Run a scan-build static analysis.
135
- scan_build:
136
- ifndef USE_SYSTEM_MINIZIP
137
- $(Q)$(MAKE) -C third_party/minizip
187
+ # Run gcov coverage analysis.
188
+ gcov: third_party
189
+ $(Q)$(MAKE) -C src clean
190
+ $(Q)$(MAKE) -C src GCOV="--coverage" OPT_LEVEL="-O0"
191
+ $(Q)$(MAKE) -C src test_lib GCOV="--coverage"
192
+ $(Q)$(MAKE) -C test/unit test GCOV="--coverage"
193
+ $(Q)$(MAKE) -C test/functional/src GCOV="--coverage"
194
+ $(Q)$(PYTEST) test/functional -v -k $(PYTESTFILES)
195
+ $(Q)mkdir -p build
196
+ $(Q)gcovr -r src --html-details -o build/libxlsxwriter_gcov.html
197
+ $(Q)gcovr -r . -f src --sonarqube build/coverage.xml
198
+
199
+ # Run sonarcloud analysis.
200
+ sonarcloud: gcov
201
+ ifndef SONAR_TOKEN
202
+ @echo "Please define SONAR_TOKEN to run this analysis."
203
+ @exit 1
138
204
  endif
139
- ifndef USE_STANDARD_TMPFILE
140
- $(Q)$(MAKE) -C third_party/tmpfileplus
205
+ $(Q)$(MAKE) clean
206
+ $(Q)../sonar-scanner-4.6.1.2450-macosx/bin/build-wrapper-macosx-x86 --out-dir build make all
207
+ $(Q)../sonar-scanner-4.6.1.2450-macosx/bin/sonar-scanner \
208
+ -Dsonar.organization=jmcnamara-github \
209
+ -Dsonar.projectKey=jmcnamara_libxlsxwriter \
210
+ -Dsonar.projectName=libxlsxwriter \
211
+ -Dsonar.projectVersion=$(VERSION) \
212
+ -Dsonar.sources=src \
213
+ -Dsonar.sourceEncoding=UTF-8 \
214
+ -Dsonar.cfamily.build-wrapper-output=build \
215
+ -Dsonar.working.directory=build/scannerwork \
216
+ -Dsonar.host.url=https://sonarcloud.io \
217
+ -Dsonar.coverageReportPaths=build/coverage.xml
218
+
219
+ sonarcloud_no_gcov:
220
+ ifndef SONAR_TOKEN
221
+ @echo "Please define SONAR_TOKEN to run this analysis."
222
+ @exit 1
141
223
  endif
142
- $(Q)$(MAKE) -C src clean
143
- $(Q)rm -f lib/*
224
+ $(Q)$(MAKE) clean
225
+ $(Q)../sonar-scanner-4.6.1.2450-macosx/bin/build-wrapper-macosx-x86 --out-dir build make all
226
+ $(Q)../sonar-scanner-4.6.1.2450-macosx/bin/sonar-scanner \
227
+ -Dsonar.organization=jmcnamara-github \
228
+ -Dsonar.projectKey=jmcnamara_libxlsxwriter \
229
+ -Dsonar.projectName=libxlsxwriter \
230
+ -Dsonar.projectVersion=$(VERSION) \
231
+ -Dsonar.sources=src \
232
+ -Dsonar.sourceEncoding=UTF-8 \
233
+ -Dsonar.cfamily.build-wrapper-output=build \
234
+ -Dsonar.working.directory=build/scannerwork \
235
+ -Dsonar.host.url=https://sonarcloud.io
236
+
237
+
238
+ # Run a scan-build static analysis.
239
+ scan_build: clean_src third_party
144
240
  $(Q)scan-build make -C src libxlsxwriter.a
145
241
  $(Q)$(MAKE) -C src clean
146
242
  $(Q)rm -f lib/*
@@ -152,14 +248,15 @@ spellcheck:
152
248
  $(Q)for f in examples/*.c; do aspell --lang=en_US --check $$f; done
153
249
  $(Q)aspell --lang=en_US --check Changes.txt
154
250
  $(Q)aspell --lang=en_US --check Readme.md
251
+ $(Q)aspell --lang=en_US --check docs/src/examples.txt
155
252
 
156
253
  releasecheck:
157
254
  $(Q)dev/release/release_check.sh
158
255
 
159
256
  release: releasecheck
160
257
  @echo
161
- @echo "Pushing to git master ..."
162
- $(Q)git push origin master
258
+ @echo "Pushing to git main ..."
259
+ $(Q)git push origin main
163
260
  $(Q)git push --tags
164
261
 
165
262
  @echo
@@ -172,7 +269,7 @@ release: releasecheck
172
269
 
173
270
  @echo
174
271
  @echo "Finished. Opening files."
175
- $(Q)open http://libxlsxwriter.github.io/changes.html
176
- $(Q)open http://cocoadocs.org/docsets/libxlsxwriter
272
+ $(Q)open https://libxlsxwriter.github.io/changes.html
273
+ $(Q)open https://cocoadocs.org/docsets/libxlsxwriter
177
274
  $(Q)open https://github.com/jmcnamara/libxlsxwriter
178
275
  $(Q)open https://github.com/jmcnamara/libxlsxwriter/releases
@@ -0,0 +1,42 @@
1
+ // swift-tools-version: 5.7
2
+ // The swift-tools-version declares the minimum version of Swift required to build this package.
3
+
4
+ import PackageDescription
5
+
6
+ let package = Package(
7
+ name: "libxlsxwriter",
8
+ products: [
9
+ .library(
10
+ name: "libxlsxwriter",
11
+ targets: ["libxlsxwriter"]),
12
+ ],
13
+ targets: [
14
+ .target(
15
+ name: "libxlsxwriter",
16
+ path: ".",
17
+ exclude: [
18
+ "src/Makefile",
19
+ ],
20
+ sources: [
21
+ "include",
22
+ "src",
23
+ "third_party/minizip/zip.c",
24
+ "third_party/minizip/ioapi.c",
25
+ "third_party/tmpfileplus/tmpfileplus.c",
26
+ "third_party/md5/md5.c"
27
+ ],
28
+ publicHeadersPath: "include",
29
+ linkerSettings: [
30
+ .linkedLibrary("z")
31
+ ]),
32
+ .testTarget(
33
+ name: "libxlsxwritertests",
34
+ dependencies: ["libxlsxwriter"],
35
+ path: ".",
36
+ sources: ["test/swift"],
37
+ linkerSettings: [
38
+ .linkedLibrary("z")
39
+ ]
40
+ )
41
+ ]
42
+ )
@@ -21,7 +21,10 @@ It supports features such as:
21
21
  - Autofilters.
22
22
  - Charts.
23
23
  - Data validation and drop down lists.
24
- - Worksheet PNG/JPEG images.
24
+ - Conditional formatting.
25
+ - Worksheet PNG/JPEG/GIF images.
26
+ - Cell comments.
27
+ - Support for adding Macros.
25
28
  - Memory optimization mode for writing large files.
26
29
  - Source code available on [GitHub](https://github.com/jmcnamara/libxlsxwriter).
27
30
  - FreeBSD license.
@@ -74,7 +77,6 @@ int main() {
74
77
  ```
75
78
 
76
79
 
77
-
78
80
  See the [full documentation](http://libxlsxwriter.github.io) for the getting
79
81
  started guide, a tutorial, the main API documentation and examples.
80
82
 
@@ -0,0 +1,324 @@
1
+ const std = @import("std");
2
+ const Path = std.Build.LazyPath;
3
+
4
+ // Although this function looks imperative, note that its job is to
5
+ // declaratively construct a build graph that will be libcuted by an external
6
+ // runner.
7
+ pub fn build(b: *std.Build) void {
8
+ // Standard target options allows the person running `zig build` to choose
9
+ // what target to build for. Here we do not override the defaults, which
10
+ // means any target is allowed, and the default is native. Other options
11
+ // for restricting supported target set are available.
12
+ const target = b.standardTargetOptions(.{});
13
+
14
+ // Standard optimization options allow the person running `zig build` to select
15
+ // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
16
+ // set a preferred release mode, allowing the user to decide how to optimize.
17
+ const optimize = b.standardOptimizeOption(.{});
18
+
19
+ const shared = b.option(bool, "SHARED_LIBRARY", "Build the Shared Library [default: false]") orelse false;
20
+ const examples = b.option(bool, "BUILD_EXAMPLES", "Build libxlsxwriter examples [default: false]") orelse false;
21
+ const tests = b.option(bool, "BUILD_TESTS", "Build libxlsxwriter tests [default: false]") orelse false;
22
+ const dtoa = b.option(bool, "USE_DTOA_LIBRARY", "Use the locale independent third party Milo Yip DTOA library [default: off]") orelse false;
23
+ const minizip = b.option(bool, "USE_SYSTEM_MINIZIP", "Use system minizip installation [default: off]") orelse false;
24
+ const md5 = b.option(bool, "USE_OPENSSL_MD5", "Build libxlsxwriter with the OpenSSL MD5 lib [default: off]") orelse false;
25
+ const stdtmpfile = b.option(bool, "USE_STANDARD_TMPFILE", "Use the C standard library's tmpfile() [default: off]") orelse false;
26
+
27
+ const lib = if (shared) b.addSharedLibrary(.{
28
+ .name = "xlsxwriter",
29
+ .target = target,
30
+ .optimize = optimize,
31
+ .version = .{
32
+ .major = 1,
33
+ .minor = 1,
34
+ .patch = 6,
35
+ },
36
+ }) else b.addStaticLibrary(.{
37
+ .name = "xlsxwriter",
38
+ .target = target,
39
+ .optimize = optimize,
40
+ });
41
+ lib.pie = true;
42
+ switch (optimize) {
43
+ .Debug, .ReleaseSafe => lib.bundle_compiler_rt = true,
44
+ else => lib.strip = true,
45
+ }
46
+ if (tests)
47
+ lib.defineCMacro("TESTING", null);
48
+ lib.addCSourceFiles(&.{
49
+ "src/vml.c",
50
+ "src/chartsheet.c",
51
+ "src/theme.c",
52
+ "src/content_types.c",
53
+ "src/xmlwriter.c",
54
+ "src/app.c",
55
+ "src/styles.c",
56
+ "src/core.c",
57
+ "src/comment.c",
58
+ "src/utility.c",
59
+ "src/metadata.c",
60
+ "src/custom.c",
61
+ "src/hash_table.c",
62
+ "src/relationships.c",
63
+ "src/drawing.c",
64
+ "src/chart.c",
65
+ "src/shared_strings.c",
66
+ "src/worksheet.c",
67
+ "src/format.c",
68
+ "src/table.c",
69
+ "src/workbook.c",
70
+ "src/packager.c",
71
+ }, cflags);
72
+
73
+ // minizip
74
+ if (minizip) {
75
+ lib.addCSourceFiles(switch (target.getOsTag()) {
76
+ .windows => minizip_src ++ [_][]const u8{
77
+ "third_party/minizip/iowin32.c",
78
+ },
79
+ else => minizip_src,
80
+ }, cflags);
81
+ }
82
+
83
+ // zig-pkg: download & build zlib (to all targets)
84
+ const zlib_dep = b.dependency("zlib", .{
85
+ .optimize = optimize,
86
+ .target = target,
87
+ });
88
+ const zlib = zlib_dep.artifact("z");
89
+ lib.linkLibrary(zlib);
90
+ lib.installLibraryHeaders(zlib);
91
+
92
+ // md5
93
+ if (!md5)
94
+ lib.addCSourceFile(.{ .file = .{ .path = "third_party/md5/md5.c" }, .flags = cflags })
95
+ else
96
+ lib.linkSystemLibrary("crypto");
97
+
98
+ // dtoa
99
+ if (dtoa)
100
+ lib.addCSourceFile(.{ .file = Path.relative("third_party/dtoa/emyg_dtoa.c"), .flags = cflags });
101
+
102
+ // tmpfileplus
103
+ if (stdtmpfile)
104
+ lib.addCSourceFile(.{ .file = .{ .path = "third_party/tmpfileplus/tmpfileplus.c" }, .flags = cflags })
105
+ else
106
+ lib.defineCMacro("USE_STANDARD_TMPFILE", null);
107
+
108
+ lib.addIncludePath(Path.relative("include"));
109
+ lib.addIncludePath(Path.relative("third_party"));
110
+ lib.linkLibC();
111
+
112
+ // get headers on include to zig-out/include
113
+ lib.installHeadersDirectory("include", "");
114
+
115
+ // get binaries on zig-cache to zig-out
116
+ b.installArtifact(lib);
117
+
118
+ // build examples
119
+ if (examples) {
120
+ buildExe(b, .{
121
+ .lib = lib,
122
+ .path = "examples/anatomy.c",
123
+ });
124
+ buildExe(b, .{
125
+ .lib = lib,
126
+ .path = "examples/array_formula.c",
127
+ });
128
+ buildExe(b, .{
129
+ .lib = lib,
130
+ .path = "examples/autofilter.c",
131
+ });
132
+ buildExe(b, .{
133
+ .lib = lib,
134
+ .path = "examples/background.c",
135
+ });
136
+ buildExe(b, .{
137
+ .lib = lib,
138
+ .path = "examples/chart_area.c",
139
+ });
140
+ buildExe(b, .{
141
+ .lib = lib,
142
+ .path = "examples/chart_column.c",
143
+ });
144
+ buildExe(b, .{
145
+ .lib = lib,
146
+ .path = "examples/data_validate.c",
147
+ });
148
+ buildExe(b, .{
149
+ .lib = lib,
150
+ .path = "examples/hello.c",
151
+ });
152
+ buildExe(b, .{
153
+ .lib = lib,
154
+ .path = "examples/watermark.c",
155
+ });
156
+ buildExe(b, .{
157
+ .lib = lib,
158
+ .path = "examples/worksheet_protection.c",
159
+ });
160
+ }
161
+ // build tests
162
+ if (tests) {
163
+ buildTest(b, .{
164
+ .lib = lib,
165
+ .path = "test/unit/app/test_app.c",
166
+ });
167
+ buildTest(b, .{
168
+ .lib = lib,
169
+ .path = "test/unit/chart/test_chart.c",
170
+ });
171
+ buildTest(b, .{
172
+ .lib = lib,
173
+ .path = "test/unit/chartsheet/test_chartsheet.c",
174
+ });
175
+ buildTest(b, .{
176
+ .lib = lib,
177
+ .path = "test/unit/content_types/test_content_types.c",
178
+ });
179
+ buildTest(b, .{
180
+ .lib = lib,
181
+ .path = "test/unit/content_types/test_content_types_write_default.c",
182
+ });
183
+ buildTest(b, .{
184
+ .lib = lib,
185
+ .path = "test/unit/content_types/test_content_types_write_override.c",
186
+ });
187
+ buildTest(b, .{
188
+ .lib = lib,
189
+ .path = "test/unit/relationships/test_relationships.c",
190
+ });
191
+ buildTest(b, .{
192
+ .lib = lib,
193
+ .path = "test/unit/app/test_app_xml_declaration.c",
194
+ });
195
+ buildTest(b, .{
196
+ .lib = lib,
197
+ .path = "test/unit/relationships/test_relationships_xml_declaration.c",
198
+ });
199
+ buildTest(b, .{
200
+ .lib = lib,
201
+ .path = "test/unit/custom/test_custom_xml_declaration.c",
202
+ });
203
+ buildTest(b, .{
204
+ .lib = lib,
205
+ .path = "test/unit/metadata/test_metadata_xml_declaration.c",
206
+ });
207
+ buildTest(b, .{
208
+ .lib = lib,
209
+ .path = "test/unit/core/test_core_xml_declaration.c",
210
+ });
211
+ buildTest(b, .{
212
+ .lib = lib,
213
+ .path = "test/unit/sst/test_shared_strings.c",
214
+ });
215
+ buildTest(b, .{
216
+ .lib = lib,
217
+ .path = "test/unit/workbook/test_workbook.c",
218
+ });
219
+ buildTest(b, .{
220
+ .lib = lib,
221
+ .path = "test/unit/xmlwriter/test_xmlwriter.c",
222
+ });
223
+ buildTest(b, .{
224
+ .lib = lib,
225
+ .path = "test/unit/table/test_table01.c",
226
+ });
227
+ buildTest(b, .{
228
+ .lib = lib,
229
+ .path = "test/unit/table/test_table02.c",
230
+ });
231
+ buildTest(b, .{
232
+ .lib = lib,
233
+ .path = "test/unit/table/test_table03.c",
234
+ });
235
+ buildTest(b, .{
236
+ .lib = lib,
237
+ .path = "test/unit/table/test_table04.c",
238
+ });
239
+ buildTest(b, .{
240
+ .lib = lib,
241
+ .path = "test/unit/styles/test_styles_write_border.c",
242
+ });
243
+ }
244
+ }
245
+
246
+ fn buildExe(b: *std.Build, info: BuildInfo) void {
247
+ const exe = b.addExecutable(.{
248
+ .name = info.filename(),
249
+ .optimize = info.lib.optimize,
250
+ .target = info.lib.target,
251
+ });
252
+ exe.addCSourceFile(.{ .file = Path.relative(info.path), .flags = cflags });
253
+ exe.linkLibrary(info.lib);
254
+ for (info.lib.include_dirs.items) |include| {
255
+ exe.include_dirs.append(include) catch {};
256
+ }
257
+ exe.linkLibC();
258
+ b.installArtifact(exe);
259
+
260
+ const run_cmd = b.addRunArtifact(exe);
261
+ run_cmd.step.dependOn(b.getInstallStep());
262
+ if (b.args) |args| {
263
+ run_cmd.addArgs(args);
264
+ }
265
+
266
+ const run_step = b.step(
267
+ b.fmt("{s}", .{info.filename()}),
268
+ b.fmt("Run the {s} test", .{info.filename()}),
269
+ );
270
+ run_step.dependOn(&run_cmd.step);
271
+ }
272
+
273
+ fn buildTest(b: *std.Build, info: BuildInfo) void {
274
+ const exe = b.addExecutable(.{
275
+ .name = info.filename(),
276
+ .optimize = info.lib.optimize,
277
+ .target = info.lib.target,
278
+ });
279
+ exe.defineCMacro("TESTING", null);
280
+ exe.addCSourceFile(.{ .file = Path.relative(info.path), .flags = cflags });
281
+ exe.addCSourceFile(.{ .file = Path.relative("test/unit/test_all.c"), .flags = cflags });
282
+ exe.addIncludePath(Path.relative("test/unit"));
283
+ for (info.lib.include_dirs.items) |include| {
284
+ exe.include_dirs.append(include) catch {};
285
+ }
286
+ exe.linkLibrary(info.lib);
287
+ exe.linkLibC();
288
+ b.installArtifact(exe);
289
+
290
+ const run_cmd = b.addRunArtifact(exe);
291
+ run_cmd.step.dependOn(b.getInstallStep());
292
+ if (b.args) |args| {
293
+ run_cmd.addArgs(args);
294
+ }
295
+
296
+ const run_step = b.step(
297
+ b.fmt("{s}", .{info.filename()}),
298
+ b.fmt("Run the {s} test", .{info.filename()}),
299
+ );
300
+ run_step.dependOn(&run_cmd.step);
301
+ }
302
+
303
+ const cflags = &.{
304
+ "-std=c89",
305
+ "-Wall",
306
+ "-Wextra",
307
+ "-Wno-unused-parameter",
308
+ };
309
+ const minizip_src: []const []const u8 = &.{
310
+ "third_party/minizip/ioapi.c",
311
+ "third_party/minizip/mztools.c",
312
+ "third_party/minizip/unzip.c",
313
+ "third_party/minizip/zip.c",
314
+ };
315
+
316
+ const BuildInfo = struct {
317
+ lib: *std.Build.Step.Compile,
318
+ path: []const u8,
319
+
320
+ fn filename(self: BuildInfo) []const u8 {
321
+ var split = std.mem.splitSequence(u8, std.fs.path.basename(self.path), ".");
322
+ return split.first();
323
+ }
324
+ };
@@ -0,0 +1,11 @@
1
+ .{
2
+ .name = "libxlsxwriter",
3
+ .version = "1.1.6",
4
+ .dependencies = .{
5
+ .zlib = .{
6
+ .url = "https://github.com/kassane/zlib/archive/4a99cc2bfa344c969f086fcb8c5873d80448f3e6.tar.gz",
7
+ .hash = "12209e851f7e2c6ba2f01de3e11b1771f03e49666065320abd8414aac152bfa75fae",
8
+ },
9
+ },
10
+ }
11
+ //syntax tip: zig - anon struct (json-like)