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
@@ -327,13 +327,13 @@ module Libxlsxwriter
327
327
  :error_zip_internal_error, 8,
328
328
  :error_zip_file_add, 9,
329
329
  :error_zip_close, 10,
330
- :error_null_parameter_ignored, 11,
331
- :error_parameter_validation, 12,
332
- :error_sheetname_length_exceeded, 13,
333
- :error_invalid_sheetname_character, 14,
334
- :error_sheetname_start_end_apostrophe, 15,
335
- :error_sheetname_already_used, 16,
336
- :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,
337
337
  :error_32_string_length_exceeded, 18,
338
338
  :error_128_string_length_exceeded, 19,
339
339
  :error_255_string_length_exceeded, 20,
@@ -1153,6 +1153,106 @@ module Libxlsxwriter
1153
1153
  :collapsed, :uchar
1154
1154
  end
1155
1155
 
1156
+ # = Fields:
1157
+ # :visible ::
1158
+ # (Integer) Make the comment visible.
1159
+ # :author ::
1160
+ # (String) Author of the comment.
1161
+ # :width ::
1162
+ # (Integer) Width of the comment box.
1163
+ # :height ::
1164
+ # (Integer) Height of the comment box.
1165
+ # :x_scale ::
1166
+ # (Float) X scale of the comment.
1167
+ # :y_scale ::
1168
+ # (Float) Y scale of the comment.
1169
+ # :color ::
1170
+ # (Integer) Background color of the comment box.
1171
+ # :font_name ::
1172
+ # (String) Font name for the comment.
1173
+ # :font_size ::
1174
+ # (Float) Font size for the comment.
1175
+ # :font_family ::
1176
+ # (Integer) Font family for the comment.
1177
+ # :start_row ::
1178
+ # (Integer) Start row for the comment box.
1179
+ # :start_col ::
1180
+ # (Integer) Start column for the comment box.
1181
+ # :x_offset ::
1182
+ # (Integer) X offset for the comment box.
1183
+ # :y_offset ::
1184
+ # (Integer) Y offset for the comment box.
1185
+ class CommentOptions < FFI::Struct
1186
+ layout :visible, :uchar,
1187
+ :author, :pointer,
1188
+ :width, :ushort,
1189
+ :height, :ushort,
1190
+ :x_scale, :double,
1191
+ :y_scale, :double,
1192
+ :color, :uint32,
1193
+ :font_name, :pointer,
1194
+ :font_size, :double,
1195
+ :font_family, :uchar,
1196
+ :start_row, :uint32,
1197
+ :start_col, :ushort,
1198
+ :x_offset, :int32,
1199
+ :y_offset, :int32
1200
+
1201
+ def initialize(*args)
1202
+ if args.first.is_a?(Hash)
1203
+ super()
1204
+ @pointers = {}
1205
+ set(args.first)
1206
+ else
1207
+ super(*args)
1208
+ @pointers = {}
1209
+ end
1210
+ end
1211
+
1212
+ def set(options)
1213
+ options.each do |k, v|
1214
+ send("#{k}=", v) if respond_to?("#{k}=")
1215
+ end
1216
+ self
1217
+ end
1218
+
1219
+ [:visible, :width, :height, :x_scale, :y_scale, :font_size, :font_family, :start_row, :start_col, :x_offset, :y_offset].each do |prop|
1220
+ define_method(prop) do
1221
+ self[prop]
1222
+ end
1223
+ define_method("#{prop}=") do |value|
1224
+ self[prop] = value
1225
+ end
1226
+ end
1227
+
1228
+ [:author, :font_name].each do |prop|
1229
+ define_method(prop) do
1230
+ ptr = self[prop]
1231
+ ptr.read_string unless ptr.null?
1232
+ end
1233
+
1234
+ define_method("#{prop}=") do |value|
1235
+ @pointers ||= {}
1236
+ if value.nil?
1237
+ @pointers.delete(prop)
1238
+ self[prop] = nil
1239
+ else
1240
+ ptr = FFI::MemoryPointer.from_string(value.to_s)
1241
+ @pointers[prop] = ptr
1242
+ self[prop] = ptr
1243
+ end
1244
+ end
1245
+ end
1246
+
1247
+ def color
1248
+ self[:color]
1249
+ end
1250
+
1251
+ def color=(value)
1252
+ self[:color] = FastExcel.color_to_hex(value)
1253
+ end
1254
+ end
1255
+
1156
1256
  require_relative 'binding/format'
1157
1257
 
1158
1258
  #
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,27 +20,24 @@ 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
36
33
 
37
34
  filename = filename.to_s if defined?(Pathname) && filename.is_a?(Pathname)
38
35
 
39
- workbook = if constant_memory
40
- opt = Libxlsxwriter::WorkbookOptions.new
41
- opt[:constant_memory] = 1
42
- Libxlsxwriter.workbook_new_opt(filename, opt)
43
- else
44
- Libxlsxwriter.workbook_new(filename)
45
- end
36
+ opt = Libxlsxwriter::WorkbookOptions.new
37
+ opt[:constant_memory] = constant_memory ? 1 : 0
38
+ opt[:tmpdir] = tmpdir || Dir.tmpdir
39
+ workbook = Libxlsxwriter.workbook_new_opt(filename, opt)
40
+
46
41
  result = Libxlsxwriter::Workbook.new(workbook)
47
42
 
48
43
  if default_format
@@ -105,23 +100,33 @@ module FastExcel
105
100
  time.to_f / XLSX_DATE_DAY + XLSX_DATE_EPOCH_DIFF + offset / XLSX_DATE_DAY
106
101
  end
107
102
 
108
- def self.print_ffi_obj(value)
109
- puts "#{value.class}"
103
+ def self.print_ffi_obj(value, do_print: true, offset: "", deep: false)
104
+ result = "#{value.class}"
105
+
110
106
  value.members.each do |key|
111
- field_val = if value[key].is_a?(FFI::Pointer) && value[key].null? || value[key].nil?
107
+ fval = value[key]
108
+ field_val = if fval.is_a?(FFI::Pointer) && fval.null? || fval.nil?
112
109
  "nil"
113
- elsif value[key].is_a?(FFI::StructLayout::CharArray)
114
- value[key].to_str.inspect
115
- elsif value[key].is_a?(String)
116
- value[key].inspect
117
- elsif value[key].is_a?(Symbol)
118
- value[key].inspect
110
+ elsif fval.is_a?(FFI::StructLayout::CharArray)
111
+ fval.to_str.inspect
112
+ elsif fval.is_a?(String)
113
+ fval.inspect
114
+ elsif fval.is_a?(Symbol)
115
+ fval.inspect
116
+ elsif fval.is_a?(FFI::Struct) && deep
117
+ print_ffi_obj(fval, do_print: false, offset: offset + " ", deep: deep)
119
118
  else
120
- value[key]
119
+ fval
121
120
  end
122
- puts "* #{key}: #{field_val}"
121
+
122
+ result += "\n#{offset}* #{key}: #{field_val}"
123
+ end
124
+
125
+ if do_print
126
+ puts result
127
+ else
128
+ return result
123
129
  end
124
- nil
125
130
  end
126
131
 
127
132
 
@@ -288,8 +293,8 @@ module FastExcel
288
293
  return EXTRA_COLORS[value.to_sym]
289
294
  elsif COLOR_ENUM.find(value.to_sym)
290
295
  return COLOR_ENUM.find(value.to_sym)
291
- elsif COLOR_ENUM.find("color_#{value.to_sym}")
292
- 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)
293
298
  elsif value =~ /^#?(0x)?([\da-f]){6}$/i
294
299
  value = value.sub('#', '') if value.start_with?('#')
295
300
  return value.start_with?('0x') ? value.to_i(16) : "0x#{value}".to_i(16)
@@ -327,8 +332,8 @@ module FastExcel
327
332
  res
328
333
  end
329
334
 
330
- def pretty_print(pp)
331
- pp fields_hash
335
+ def pretty_print(pp_obj)
336
+ fields_hash.pretty_print(pp_obj)
332
337
  end
333
338
  end
334
339
 
@@ -383,9 +388,12 @@ module FastExcel
383
388
  end
384
389
 
385
390
  def get_worksheet_by_name(name)
386
- sheet = super(name)
387
- sheet.workbook = self
391
+ return nil if name.nil? || !@sheet_names.include?(name.to_s)
392
+
393
+ sheet = super(name.to_s)
394
+ return nil if sheet.nil?
388
395
 
396
+ sheet.workbook = self
389
397
  sheet
390
398
  end
391
399
 
@@ -536,12 +544,12 @@ module FastExcel
536
544
  end
537
545
 
538
546
  def enable_filters!(start_col: 0, end_col:)
539
- autofilter(start_col, 0, @last_row_number, end_col)
547
+ autofilter(0, start_col, @last_row_number, end_col)
540
548
  end
541
549
 
542
550
  def close
543
551
  if auto_width?
544
- @column_widths.each do |num, width|
552
+ @column_widths.transform_values!{ |width| width || DEF_COL_WIDTH }.each do |num, width|
545
553
  set_column_width(num, width + 0.2)
546
554
  end
547
555
  end
@@ -0,0 +1 @@
1
+ custom: ["paypal.me/xlsxwriter"]
@@ -0,0 +1,85 @@
1
+ # libxlsxwriter: Reporting Bugs
2
+
3
+ Here are some tips on reporting bugs in `libxlsxwriter`.
4
+
5
+ ### Upgrade to the latest version of the library
6
+
7
+ Upgrade to the latest version of the library since the bug you are reporting
8
+ may already be fixed.
9
+
10
+ Check the [Changes][changes] section of the documentation to see what has
11
+ changed in the latest versions.
12
+
13
+ [changes]: http://libxlsxwriter.github.io/changes.html
14
+
15
+ You can check which version of `libxlsxwriter` that you are using by checking
16
+ the `xlsxwriter.h` header file or by adding the following to your program:
17
+
18
+ ```C
19
+ #include <stdio.h>
20
+ #include "xlsxwriter.h"
21
+
22
+ int main() {
23
+
24
+ printf("Libxlsxwriter version = %s\n", lxw_version());
25
+
26
+ return 0;
27
+ }
28
+ ```
29
+
30
+ ### Read the documentation
31
+
32
+ Read or search the `libxlsxwriter` [documentation][docs] to see if the issue
33
+ you are encountering is already explained.
34
+
35
+ [docs]: http://libxlsxwriter.github.io/index.html
36
+
37
+ ### Look at the example programs
38
+
39
+ There are many [examples programs][examples] in the distribution. Try to
40
+ identify an example program that corresponds to your query and adapt it to use
41
+ as a bug report.
42
+
43
+ [examples]: http://libxlsxwriter.github.io/examples.html
44
+
45
+
46
+ ### Tips for submitting a bug report
47
+
48
+ 1. Describe the problem as clearly and as concisely as possible.
49
+ 2. Include a sample program. This is probably the most important step.
50
+ It is generally easier to describe a problem in code than in written
51
+ prose.
52
+ 3. The sample program should be as small as possible to demonstrate the
53
+ problem. Don't copy and paste large non-relevant sections of your
54
+ program.
55
+
56
+ A sample bug report is shown below. This format helps analyze and respond to
57
+ the bug report more quickly.
58
+
59
+
60
+ > Subject: Issue with SOMETHING
61
+ >
62
+ > Greetings,
63
+ >
64
+ > I am using libxlsxwriter to do SOMETHING but it appears to do SOMETHING ELSE.
65
+ >
66
+ > I am using CC version X.Y.Z, OS = uname and libxlsxwriter x.y.z.
67
+ >
68
+ > Here is some code that demonstrates the problem:
69
+ >
70
+ >
71
+ >```C
72
+ >#include "xlsxwriter.h"
73
+ >
74
+ >int main() {
75
+ >
76
+ > lxw_workbook *workbook = workbook_new("bug_report.xlsx");
77
+ > lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
78
+ >
79
+ > worksheet_write_string(worksheet, 0, 0, "Hello", NULL);
80
+ > worksheet_write_number(worksheet, 1, 0, 123, NULL);
81
+ >
82
+ > return workbook_close(workbook);
83
+ >}
84
+ >```
85
+ >
@@ -0,0 +1,130 @@
1
+ # libxlsxwriter: Submitting Pull Requests
2
+
3
+ # Pull Requests and Contributing to Libxlsxwriter
4
+
5
+ All patches and pull requests are welcome but in general you should start with
6
+ an issue tracker to describe what you intend to do before you do it.
7
+
8
+
9
+ ### Getting Started
10
+
11
+ 1. Pull requests and new feature proposals must start with an [issue
12
+ tracker][issues]. This serves as the focal point for the design discussion.
13
+ 2. Describe what you plan to do. If there are API changes add some code
14
+ example to demonstrate them.
15
+ 3. Fork the repository.
16
+ 4. Run all the tests to make sure the current code works on your system using
17
+ `make test`. See the [Running the Test Suite][tests] section of the docs
18
+ for instructions.
19
+ 5. Create a feature branch for your new feature.
20
+
21
+
22
+ [tests]: http://libxlsxwriter.github.io/running_the_tests.html
23
+
24
+ ### Code Style
25
+
26
+ The code style is mainly K&R style with 4 space indents.
27
+
28
+ The author uses GNU indent (`gindent`) 2.2.10 with the following options:
29
+
30
+ ```
31
+ --braces-on-if-line
32
+ --braces-on-struct-decl-line
33
+ --case-indentation 4
34
+ --continue-at-parentheses
35
+ --declaration-comment-column 0
36
+ --format-first-column-comments
37
+ --honour-newlines
38
+ --ignore-profile
39
+ --indent-label 0
40
+ --indent-level 4
41
+ --no-space-after-function-call-names
42
+ --no-tabs
43
+ --swallow-optional-blank-lines
44
+ ```
45
+
46
+ The [indent configuration file][indentpro] is available in the repo. The code
47
+ can be indented automatically if the same version of `gindent` is used with
48
+ the following make command:
49
+
50
+ ```shell
51
+ make indent
52
+ ```
53
+
54
+ Note, make sure you have backed up your files or added them to the index
55
+ before running this command.
56
+
57
+ In general follow the existing style in the code.
58
+
59
+ [indentpro]: https://github.com/jmcnamara/libxlsxwriter/blob/master/.indent.pro
60
+
61
+ ### Writing and Running Tests
62
+
63
+ Any significant features should be accompanied by a test. See the `test`
64
+ directory and the [Running the Test Suite][tests] section of the docs for
65
+ details of the test setup.
66
+
67
+ The tests can be run as follows:
68
+
69
+ ```shell
70
+ make test
71
+ ```
72
+ Same as:
73
+
74
+ ```shell
75
+ make test_unit
76
+ make test_functional
77
+ ```
78
+
79
+ The functional tests require the Python module [pytest][pytest] as a test runner.
80
+
81
+ If you have `valgrind` installed you can use the test suite to check for memory leaks:
82
+
83
+ ```shell
84
+ make test_valgrind
85
+ ```
86
+
87
+ When you push your changes they will also be tested automatically using
88
+ [GitHub Actions][actions].
89
+
90
+ [actions]: https://github.com/jmcnamara/libxlsxwriter/actions
91
+ [pytest]: http://pytest.org/
92
+
93
+
94
+ ### Documentation
95
+
96
+ The `libxlsxwriter` documentation is written in Doxygen format in the header
97
+ files and in additional `.dox` files in the `docs/src` directory of the
98
+ repo. The documentation can be built as follows:
99
+
100
+ ```shell
101
+ make docs
102
+ open docs/html/index.html
103
+ ```
104
+
105
+
106
+ ### Example programs
107
+
108
+ If applicable add an example program to the `examples` directory. Example
109
+ files can be built using:
110
+
111
+ ```shell
112
+ make docs
113
+ ```
114
+
115
+ ### Copyright and License
116
+
117
+ Copyright remains with the original author. Do not include additional
118
+ copyright claims or Licensing requirements. GitHub and the `git` repository
119
+ will record your contribution and it will be acknowledged it in the Changes
120
+ file.
121
+
122
+
123
+ ### Submitting the Pull Request
124
+
125
+ If your change involves several incremental `git` commits then `rebase` or
126
+ `squash` them onto another branch so that the Pull Request is a single commit
127
+ or a small number of logical commits.
128
+
129
+ Push your changes to GitHub and submit the Pull Request with a hash link to
130
+ the to the Issue tracker that was opened above.
@@ -0,0 +1,48 @@
1
+ name: Test CMake build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name:
8
+ Cmake
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ cc: [gcc, clang]
13
+ cmake_flags: ["",
14
+ "-DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON",
15
+ "-DUSE_DTOA_LIBRARY=ON -DBUILD_TESTS=ON",
16
+ "-DUSE_MEM_FILE=ON -DBUILD_TESTS=ON",
17
+ "-DUSE_NO_MD5=ON -DBUILD_TESTS=ON",
18
+ "-DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
19
+ "-DUSE_STANDARD_TMPFILE=ON -DBUILD_TESTS=ON",
20
+ "-DUSE_SYSTEM_MINIZIP=ON -DBUILD_TESTS=ON",
21
+ "-DUSE_SYSTEM_MINIZIP=ON -DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON"]
22
+ runs-on: ubuntu-latest
23
+ env:
24
+ CC: ${{ matrix.cc }}
25
+
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+
29
+ - name: Install dependencies
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install pytest
33
+ sudo apt update
34
+ sudo apt-get -y install zlib1g-dev
35
+ sudo apt-get -y install libminizip-dev
36
+ sudo apt-get -y install libssl-dev
37
+
38
+ - name: Configure CMake
39
+ working-directory: ${{ github.workspace }}/cmake
40
+ run: cmake .. -DBUILD_TESTS=ON ${{ matrix.cmake_flags }} -DCMAKE_BUILD_TYPE=Release
41
+
42
+ - name: Build
43
+ working-directory: ${{ github.workspace }}/cmake
44
+ run: cmake --build . --config Release --parallel
45
+
46
+ - name: Test
47
+ working-directory: ${{ github.workspace }}/cmake
48
+ run: ctest -C Release -V
@@ -0,0 +1,23 @@
1
+ name: Check code style
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name:
8
+ Check code style
9
+
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+
15
+ - name: Install dependencies
16
+ run: |
17
+ sudo apt-get -y install indent
18
+ sudo ln -s /usr/bin/indent /usr/bin/gindent
19
+
20
+ - name: Make indent
21
+ run: |
22
+ make indent
23
+ git status | grep 'nothing to commit'
@@ -0,0 +1,22 @@
1
+ name: Coverity Scan
2
+
3
+ on:
4
+ push:
5
+ branches: [coverity]
6
+
7
+ jobs:
8
+ coverity:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+
12
+ - uses: actions/checkout@v2
13
+
14
+ - name: Build third party libs to exclude them from scan
15
+ run: make third_party
16
+
17
+ - uses: vapier/coverity-scan-action@v1
18
+ with:
19
+ project: libxlsxwriter
20
+ email: ${{ secrets.COVERITY_SCAN_EMAIL }}
21
+ token: ${{ secrets.COVERITY_SCAN_TOKEN }}
22
+ command: make -C src libxlsxwriter.a
@@ -0,0 +1,52 @@
1
+ name: Test Make 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: ["",
14
+ "USE_STANDARD_TMPFILE=1",
15
+ "USE_SYSTEM_MINIZIP=1",
16
+ "USE_DTOA_LIBRARY=1",
17
+ "USE_NO_MD5=1",
18
+ "USE_OPENSSL_MD5=1",
19
+ "USE_MEM_FILE=1"]
20
+ runs-on: ubuntu-latest
21
+ env:
22
+ CC: ${{ matrix.cc }}
23
+ CXX: ${{ matrix.cc }}
24
+ CFLAGS: '-Werror'
25
+
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+
29
+ - name: Install dependencies
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install pytest
33
+ sudo apt update
34
+ sudo apt-get -y install zlib1g-dev
35
+ sudo apt-get -y install libminizip-dev
36
+ sudo apt-get -y install libssl-dev
37
+ sudo apt-get -y install valgrind
38
+
39
+ - name: make
40
+ run: ${{ matrix.make_flags }} make V=1
41
+
42
+ - name: test unit
43
+ run: ${{ matrix.make_flags }} make test_unit V=1
44
+
45
+ - name: test functional
46
+ run: ${{ matrix.make_flags }} make test_functional V=1 -j
47
+
48
+ - name: test cpp
49
+ run: ${{ matrix.make_flags }} make test_cpp V=1
50
+
51
+ - name: test examples
52
+ run: ${{ matrix.make_flags }} make examples V=1
@@ -0,0 +1,23 @@
1
+ name: Test for memory leaks
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name:
8
+ Valgrind
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ CC: gcc
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+
16
+ - name: Install dependencies
17
+ run: |
18
+ sudo apt update
19
+ sudo apt-get -y install valgrind
20
+ sudo apt-get -y install zlib1g-dev
21
+
22
+ - name: test valgrind
23
+ run: make test_valgrind V=1 -j 2