xlsxwriter 0.2.1.pre.2 → 0.2.3.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -3
  3. data/ext/xlsxwriter/chart.c +84 -20
  4. data/ext/xlsxwriter/chart.h +1 -0
  5. data/ext/xlsxwriter/chartsheet.c +34 -13
  6. data/ext/xlsxwriter/common.h +5 -5
  7. data/ext/xlsxwriter/extconf.rb +8 -8
  8. data/ext/xlsxwriter/libxlsxwriter/License.txt +24 -2
  9. data/ext/xlsxwriter/libxlsxwriter/Makefile +46 -12
  10. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +1 -1
  11. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +196 -30
  12. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chartsheet.h +3 -3
  13. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  14. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +24 -5
  15. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +5 -1
  16. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  17. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  18. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +6 -17
  19. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +20 -6
  20. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  21. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +3 -1
  22. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  23. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  24. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +11 -5
  25. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  26. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/md5.h +43 -0
  27. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +42 -3
  28. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  29. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +83 -18
  30. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +1519 -109
  31. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +4 -2
  32. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +3 -2
  33. data/ext/xlsxwriter/libxlsxwriter/src/Makefile +25 -7
  34. data/ext/xlsxwriter/libxlsxwriter/src/app.c +1 -1
  35. data/ext/xlsxwriter/libxlsxwriter/src/chart.c +332 -48
  36. data/ext/xlsxwriter/libxlsxwriter/src/chartsheet.c +20 -19
  37. data/ext/xlsxwriter/libxlsxwriter/src/comment.c +443 -0
  38. data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +20 -1
  39. data/ext/xlsxwriter/libxlsxwriter/src/core.c +2 -2
  40. data/ext/xlsxwriter/libxlsxwriter/src/custom.c +1 -1
  41. data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +58 -20
  42. data/ext/xlsxwriter/libxlsxwriter/src/format.c +98 -25
  43. data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +1 -1
  44. data/ext/xlsxwriter/libxlsxwriter/src/packager.c +269 -12
  45. data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +1 -1
  46. data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +2 -4
  47. data/ext/xlsxwriter/libxlsxwriter/src/styles.c +334 -48
  48. data/ext/xlsxwriter/libxlsxwriter/src/theme.c +1 -1
  49. data/ext/xlsxwriter/libxlsxwriter/src/utility.c +71 -8
  50. data/ext/xlsxwriter/libxlsxwriter/src/vml.c +1032 -0
  51. data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +343 -27
  52. data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +3759 -478
  53. data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +81 -2
  54. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/Makefile +42 -0
  55. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/md5.c +291 -0
  56. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/md5.h +43 -0
  57. data/ext/xlsxwriter/rich_string.c +28 -9
  58. data/ext/xlsxwriter/shared_strings.c +75 -0
  59. data/ext/xlsxwriter/shared_strings.h +15 -0
  60. data/ext/xlsxwriter/workbook.c +87 -13
  61. data/ext/xlsxwriter/workbook.h +1 -0
  62. data/ext/xlsxwriter/workbook_properties.c +2 -2
  63. data/ext/xlsxwriter/worksheet.c +75 -23
  64. data/ext/xlsxwriter/worksheet.h +1 -0
  65. data/ext/xlsxwriter/xlsxwriter.c +2 -0
  66. data/lib/xlsxwriter/rich_string.rb +0 -2
  67. data/lib/xlsxwriter/version.rb +1 -1
  68. data/lib/xlsxwriter/worksheet.rb +2 -2
  69. data/test/{run-test.rb → run_test.rb} +3 -3
  70. data/test/support/chart_test.rb +3 -3
  71. data/test/support/with_xlsx_file.rb +4 -2
  72. data/test/support/xlsx_comparable.rb +40 -26
  73. data/test/test_array_formula.rb +42 -0
  74. data/test/test_autofilter.rb +72 -0
  75. data/test/{test-chart-area.rb → test_chart_area.rb} +2 -2
  76. data/test/{test-chart-axis.rb → test_chart_axis.rb} +16 -16
  77. data/test/test_chart_bar.rb +382 -0
  78. data/test/test_chart_blank.rb +27 -0
  79. data/test/{test-chart-column.rb → test_chart_column.rb} +2 -2
  80. data/test/{test-chart-doughnut.rb → test_chart_doughnut.rb} +2 -2
  81. data/test/{test-chart-legend.rb → test_chart_legend.rb} +2 -2
  82. data/test/{test-chart-pie.rb → test_chart_pie.rb} +2 -2
  83. data/test/{test-chart-scatter.rb → test_chart_scatter.rb} +3 -4
  84. data/test/{test-chart-size.rb → test_chart_size.rb} +2 -2
  85. data/test/{test-chart-title.rb → test_chart_title.rb} +3 -3
  86. data/test/{test-chartsheet.rb → test_chartsheet.rb} +2 -2
  87. data/test/{test-data.rb → test_data.rb} +1 -1
  88. data/test/{test-data-validation.rb → test_data_validation.rb} +23 -24
  89. data/test/{test-default-row.rb → test_default_row.rb} +1 -1
  90. data/test/{test-defined-name.rb → test_defined_name.rb} +12 -12
  91. data/test/{test-escapes.rb → test_escapes.rb} +5 -2
  92. data/test/{test-fit-to-pages.rb → test_fit_to_pages.rb} +6 -6
  93. data/test/{test-formatting.rb → test_formatting.rb} +10 -10
  94. data/test/{test-gridlines.rb → test_gridlines.rb} +3 -3
  95. data/test/{test-hyperlink.rb → test_hyperlink.rb} +22 -11
  96. data/test/{test-image.rb → test_image.rb} +6 -4
  97. data/test/{test-macro.rb → test_macro.rb} +1 -1
  98. data/test/{test-merge-range.rb → test_merge_range.rb} +1 -1
  99. data/test/{test-misc.rb → test_misc.rb} +2 -2
  100. data/test/{test-optimize.rb → test_optimize.rb} +2 -4
  101. data/test/{test-outline.rb → test_outline.rb} +14 -14
  102. data/test/{test-page-breaks.rb → test_page_breaks.rb} +2 -2
  103. data/test/{test-page-setup.rb → test_page_setup.rb} +2 -2
  104. data/test/{test-panes.rb → test_panes.rb} +1 -1
  105. data/test/{test-print-area.rb → test_print_area.rb} +3 -3
  106. data/test/{test-print-options.rb → test_print_options.rb} +7 -7
  107. data/test/{test-print-scale.rb → test_print_scale.rb} +2 -2
  108. data/test/{test-properties.rb → test_properties.rb} +2 -2
  109. data/test/{test-protect.rb → test_protect.rb} +3 -3
  110. data/test/{test-repeat.rb → test_repeat.rb} +3 -3
  111. data/test/{test-rich-string.rb → test_rich_string.rb} +5 -9
  112. data/test/{test-row-col-format.rb → test_row_col_format.rb} +1 -1
  113. data/test/{test-ruby-worksheet.rb → test_ruby_worksheet.rb} +2 -2
  114. data/test/{test-set-selection.rb → test_set_selection.rb} +2 -2
  115. data/test/{test-set-start-page.rb → test_set_start_page.rb} +2 -2
  116. data/test/{test-simple.rb → test_simple.rb} +10 -10
  117. data/test/{test-types.rb → test_types.rb} +1 -1
  118. data/test/{xlsx-func-testcase.rb → xlsx_func_testcase.rb} +1 -0
  119. metadata +127 -106
  120. data/test/test-array-formula.rb +0 -35
  121. data/test/test-autofilter.rb +0 -72
  122. data/test/test-chart-bar.rb +0 -74
  123. /data/test/{test-errors.rb → test_errors.rb} +0 -0
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Used in conjunction with the libxlsxwriter library.
5
5
  *
6
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
6
+ * Copyright 2014-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
7
7
  *
8
8
  */
9
9
 
@@ -13,6 +13,7 @@
13
13
  #include <stdint.h>
14
14
  #include <stdlib.h>
15
15
  #include "xlsxwriter.h"
16
+ #include "xlsxwriter/common.h"
16
17
  #include "xlsxwriter/third_party/tmpfileplus.h"
17
18
 
18
19
  char *error_strings[LXW_MAX_ERRNO + 1] = {
@@ -27,19 +28,20 @@ char *error_strings[LXW_MAX_ERRNO + 1] = {
27
28
  "Zip error ZIP_INTERNALERROR while creating the xlsx file.",
28
29
  "File error or unknown zip error when adding sub file to xlsx file.",
29
30
  "Unknown zip error when closing xlsx file.",
31
+ "Feature is not currently supported in this configuration.",
30
32
  "NULL function parameter ignored.",
31
33
  "Function parameter validation error.",
32
34
  "Worksheet name exceeds Excel's limit of 31 characters.",
33
35
  "Worksheet name cannot contain invalid characters: '[ ] : * ? / \\'",
34
36
  "Worksheet name cannot start or end with an apostrophe.",
35
37
  "Worksheet name is already in use.",
36
- "Worksheet name 'History' is reserved by Excel.",
37
38
  "Parameter exceeds Excel's limit of 32 characters.",
38
39
  "Parameter exceeds Excel's limit of 128 characters.",
39
40
  "Parameter exceeds Excel's limit of 255 characters.",
40
41
  "String exceeds Excel's limit of 32,767 characters.",
41
42
  "Error finding internal string index.",
42
43
  "Worksheet row or column index out of range.",
44
+ "Maximum hyperlink length (2079) exceeded.",
43
45
  "Maximum number of worksheet URLs (65530) exceeded.",
44
46
  "Couldn't read image dimensions or DPI.",
45
47
  "Unknown error number."
@@ -62,7 +64,7 @@ lxw_col_to_name(char *col_name, lxw_col_t col_num, uint8_t absolute)
62
64
  {
63
65
  uint8_t pos = 0;
64
66
  size_t len;
65
- uint8_t i;
67
+ size_t i;
66
68
 
67
69
  /* Change from 0 index to 1 index. */
68
70
  col_num++;
@@ -312,10 +314,11 @@ lxw_name_to_col_2(const char *col_str)
312
314
  }
313
315
 
314
316
  /*
315
- * Convert a lxw_datetime struct to an Excel serial date.
317
+ * Convert a lxw_datetime struct to an Excel serial date, with a 1900
318
+ * or 1904 epoch.
316
319
  */
317
320
  double
318
- lxw_datetime_to_excel_date(lxw_datetime *datetime, uint8_t date_1904)
321
+ lxw_datetime_to_excel_date_epoch(lxw_datetime *datetime, uint8_t date_1904)
319
322
  {
320
323
  int year = datetime->year;
321
324
  int month = datetime->month;
@@ -407,6 +410,15 @@ lxw_datetime_to_excel_date(lxw_datetime *datetime, uint8_t date_1904)
407
410
  return days + seconds;
408
411
  }
409
412
 
413
+ /*
414
+ * Convert a lxw_datetime struct to an Excel serial date, for the 1900 epoch.
415
+ */
416
+ double
417
+ lxw_datetime_to_excel_datetime(lxw_datetime *datetime)
418
+ {
419
+ return lxw_datetime_to_excel_date_epoch(datetime, LXW_FALSE);
420
+ }
421
+
410
422
  /* Simple strdup() implementation since it isn't ANSI C. */
411
423
  char *
412
424
  lxw_strdup(const char *str)
@@ -561,7 +573,7 @@ lxw_sprintf_dbl(char *data, double number)
561
573
  #endif
562
574
 
563
575
  /*
564
- * Retrieve runtime library version
576
+ * Retrieve runtime library version.
565
577
  */
566
578
  const char *
567
579
  lxw_version(void)
@@ -569,6 +581,15 @@ lxw_version(void)
569
581
  return LXW_VERSION;
570
582
  }
571
583
 
584
+ /*
585
+ * Retrieve runtime library version ID.
586
+ */
587
+ uint16_t
588
+ lxw_version_id(void)
589
+ {
590
+ return LXW_VERSION_ID;
591
+ }
592
+
572
593
  /*
573
594
  * Hash a worksheet password. Based on the algorithm provided by Daniel Rentz
574
595
  * of OpenOffice.
@@ -577,12 +598,12 @@ uint16_t
577
598
  lxw_hash_password(const char *password)
578
599
  {
579
600
  size_t count;
580
- uint8_t i;
601
+ size_t i;
581
602
  uint16_t hash = 0x0000;
582
603
 
583
604
  count = strlen(password);
584
605
 
585
- for (i = 0; i < count; i++) {
606
+ for (i = 0; i < (uint8_t) count; i++) {
586
607
  uint32_t low_15;
587
608
  uint32_t high_15;
588
609
  uint32_t letter = password[i] << (i + 1);
@@ -600,3 +621,45 @@ lxw_hash_password(const char *password)
600
621
 
601
622
  return hash;
602
623
  }
624
+
625
+ /* Make a simple portable version of fopen() for Windows. */
626
+ #ifdef __MINGW32__
627
+ #undef _WIN32
628
+ #endif
629
+
630
+ #ifdef _WIN32
631
+
632
+ #include <windows.h>
633
+
634
+ FILE *
635
+ lxw_fopen(const char *filename, const char *mode)
636
+ {
637
+ int n;
638
+ wchar_t wide_filename[_MAX_PATH + 1] = L"";
639
+ wchar_t wide_mode[_MAX_PATH + 1] = L"";
640
+
641
+ n = MultiByteToWideChar(CP_UTF8, 0, filename, (int) strlen(filename),
642
+ wide_filename, _MAX_PATH);
643
+
644
+ if (n == 0) {
645
+ LXW_ERROR("MultiByteToWideChar error: filename");
646
+ return NULL;
647
+ }
648
+
649
+ n = MultiByteToWideChar(CP_UTF8, 0, mode, (int) strlen(mode),
650
+ wide_mode, _MAX_PATH);
651
+
652
+ if (n == 0) {
653
+ LXW_ERROR("MultiByteToWideChar error: mode");
654
+ return NULL;
655
+ }
656
+
657
+ return _wfopen(wide_filename, wide_mode);
658
+ }
659
+ #else
660
+ FILE *
661
+ lxw_fopen(const char *filename, const char *mode)
662
+ {
663
+ return fopen(filename, mode);
664
+ }
665
+ #endif