fast_excel 0.2.6 → 0.3.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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +2 -0
  3. data/.gitignore +3 -0
  4. data/.travis.yml +18 -6
  5. data/CHANGELOG.md +14 -1
  6. data/Dockerfile.test +16 -0
  7. data/Gemfile +1 -1
  8. data/Gemfile.lock +21 -21
  9. data/Makefile +13 -2
  10. data/README.md +148 -38
  11. data/Rakefile +2 -0
  12. data/examples/example.rb +3 -3
  13. data/examples/example_filters.rb +36 -0
  14. data/examples/example_formula.rb +1 -3
  15. data/examples/example_hyperlink.rb +20 -0
  16. data/fast_excel.gemspec +1 -1
  17. data/lib/fast_excel.rb +36 -12
  18. data/lib/fast_excel/binding.rb +31 -21
  19. data/lib/fast_excel/binding/chart.rb +20 -1
  20. data/lib/fast_excel/binding/workbook.rb +10 -2
  21. data/lib/fast_excel/binding/worksheet.rb +44 -27
  22. data/libxlsxwriter/.gitignore +1 -0
  23. data/libxlsxwriter/.indent.pro +5 -0
  24. data/libxlsxwriter/CMakeLists.txt +1 -11
  25. data/libxlsxwriter/CONTRIBUTING.md +1 -1
  26. data/libxlsxwriter/Changes.txt +84 -0
  27. data/libxlsxwriter/LICENSE.txt +1 -1
  28. data/libxlsxwriter/Makefile +7 -5
  29. data/libxlsxwriter/Readme.md +1 -1
  30. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +1 -0
  31. data/libxlsxwriter/include/xlsxwriter.h +2 -2
  32. data/libxlsxwriter/include/xlsxwriter/app.h +2 -2
  33. data/libxlsxwriter/include/xlsxwriter/chart.h +56 -6
  34. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +544 -0
  35. data/libxlsxwriter/include/xlsxwriter/common.h +27 -6
  36. data/libxlsxwriter/include/xlsxwriter/content_types.h +5 -2
  37. data/libxlsxwriter/include/xlsxwriter/core.h +2 -2
  38. data/libxlsxwriter/include/xlsxwriter/custom.h +2 -2
  39. data/libxlsxwriter/include/xlsxwriter/drawing.h +3 -2
  40. data/libxlsxwriter/include/xlsxwriter/format.h +3 -3
  41. data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  42. data/libxlsxwriter/include/xlsxwriter/packager.h +13 -8
  43. data/libxlsxwriter/include/xlsxwriter/relationships.h +2 -2
  44. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +5 -3
  45. data/libxlsxwriter/include/xlsxwriter/styles.h +9 -4
  46. data/libxlsxwriter/include/xlsxwriter/theme.h +2 -2
  47. data/libxlsxwriter/include/xlsxwriter/utility.h +26 -2
  48. data/libxlsxwriter/include/xlsxwriter/workbook.h +232 -55
  49. data/libxlsxwriter/include/xlsxwriter/worksheet.h +264 -53
  50. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +3 -1
  51. data/libxlsxwriter/libxlsxwriter.podspec +1 -1
  52. data/libxlsxwriter/src/Makefile +3 -3
  53. data/libxlsxwriter/src/app.c +2 -2
  54. data/libxlsxwriter/src/chart.c +41 -5
  55. data/libxlsxwriter/src/chartsheet.c +508 -0
  56. data/libxlsxwriter/src/content_types.c +12 -4
  57. data/libxlsxwriter/src/core.c +2 -2
  58. data/libxlsxwriter/src/custom.c +2 -2
  59. data/libxlsxwriter/src/drawing.c +114 -17
  60. data/libxlsxwriter/src/format.c +3 -3
  61. data/libxlsxwriter/src/hash_table.c +1 -1
  62. data/libxlsxwriter/src/packager.c +369 -65
  63. data/libxlsxwriter/src/relationships.c +2 -2
  64. data/libxlsxwriter/src/shared_strings.c +18 -4
  65. data/libxlsxwriter/src/styles.c +56 -9
  66. data/libxlsxwriter/src/theme.c +2 -2
  67. data/libxlsxwriter/src/utility.c +53 -6
  68. data/libxlsxwriter/src/workbook.c +372 -56
  69. data/libxlsxwriter/src/worksheet.c +425 -76
  70. data/libxlsxwriter/src/xmlwriter.c +17 -8
  71. data/libxlsxwriter/third_party/minizip/ioapi.c +10 -0
  72. data/libxlsxwriter/third_party/minizip/zip.c +2 -0
  73. data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +2 -2
  74. data/libxlsxwriter/version.txt +1 -1
  75. data/test/tmpfile_test.rb +1 -0
  76. data/test/validations_test.rb +26 -6
  77. data/test/worksheet_test.rb +43 -0
  78. metadata +9 -6
  79. data/libxlsxwriter/.drone.yml +0 -27
  80. data/libxlsxwriter/appveyor.yml +0 -65
  81. data/libxlsxwriter/cmake/FindZLIB.cmake +0 -123
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2018, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  */
6
6
 
7
7
  /**
@@ -53,18 +53,19 @@
53
53
  #include "drawing.h"
54
54
  #include "common.h"
55
55
  #include "format.h"
56
+ #include "styles.h"
56
57
  #include "utility.h"
57
58
 
58
- #define LXW_ROW_MAX 1048576
59
- #define LXW_COL_MAX 16384
60
- #define LXW_COL_META_MAX 128
59
+ #define LXW_ROW_MAX 1048576
60
+ #define LXW_COL_MAX 16384
61
+ #define LXW_COL_META_MAX 128
61
62
  #define LXW_HEADER_FOOTER_MAX 255
62
- #define LXW_MAX_NUMBER_URLS 65530
63
- #define LXW_PANE_NAME_LENGTH 12 /* bottomRight + 1 */
63
+ #define LXW_MAX_NUMBER_URLS 65530
64
+ #define LXW_PANE_NAME_LENGTH 12 /* bottomRight + 1 */
64
65
 
65
66
  /* The Excel 2007 specification says that the maximum number of page
66
67
  * breaks is 1026. However, in practice it is actually 1023. */
67
- #define LXW_BREAKS_MAX 1023
68
+ #define LXW_BREAKS_MAX 1023
68
69
 
69
70
  /** Default column width in Excel */
70
71
  #define LXW_DEF_COL_WIDTH (double)8.43
@@ -205,6 +206,7 @@ enum cell_types {
205
206
  NUMBER_CELL = 1,
206
207
  STRING_CELL,
207
208
  INLINE_STRING_CELL,
209
+ INLINE_RICH_STRING_CELL,
208
210
  FORMULA_CELL,
209
211
  ARRAY_FORMULA_CELL,
210
212
  BLANK_CELL,
@@ -546,6 +548,7 @@ typedef struct lxw_image_options {
546
548
  lxw_row_t row;
547
549
  lxw_col_t col;
548
550
  char *filename;
551
+ char *description;
549
552
  char *url;
550
553
  char *tip;
551
554
  uint8_t anchor;
@@ -553,9 +556,11 @@ typedef struct lxw_image_options {
553
556
  /* Internal metadata. */
554
557
  FILE *stream;
555
558
  uint8_t image_type;
559
+ uint8_t is_image_buffer;
560
+ unsigned char *image_buffer;
561
+ size_t image_buffer_size;
556
562
  double width;
557
563
  double height;
558
- char *short_name;
559
564
  char *extension;
560
565
  double x_dpi;
561
566
  double y_dpi;
@@ -623,15 +628,39 @@ typedef struct lxw_protection {
623
628
  /** Protect scenarios. */
624
629
  uint8_t scenarios;
625
630
 
626
- /** Protect drawing objects. */
631
+ /** Protect drawing objects. Worksheets only. */
627
632
  uint8_t objects;
628
633
 
634
+ /** Turn off chartsheet content protection. */
635
+ uint8_t no_content;
636
+
637
+ /** Turn off chartsheet objects. */
638
+ uint8_t no_objects;
639
+
629
640
  uint8_t no_sheet;
630
- uint8_t content;
631
641
  uint8_t is_configured;
632
642
  char hash[5];
633
643
  } lxw_protection;
634
644
 
645
+ /**
646
+ * @brief Struct to represent a rich string format/string pair.
647
+ *
648
+ * Arrays of this struct are used to define "rich" multi-format strings that
649
+ * are passed to `worksheet_write_rich_string()`. Each struct represents a
650
+ * fragment of the rich multi-format string with a lxw_format to define the
651
+ * format for the string part. If the string fragment is unformatted then
652
+ * `NULL` can be used for the format.
653
+ */
654
+ typedef struct lxw_rich_string_tuple {
655
+
656
+ /** The format for a string fragment in a rich string. NULL if the string
657
+ * isn't formatted. */
658
+ lxw_format *format;
659
+
660
+ /** The string fragment. */
661
+ char *string;
662
+ } lxw_rich_string_tuple;
663
+
635
664
  /**
636
665
  * @brief Struct to represent an Excel worksheet.
637
666
  *
@@ -668,6 +697,7 @@ typedef struct lxw_worksheet {
668
697
  uint8_t hidden;
669
698
  uint16_t *active_sheet;
670
699
  uint16_t *first_sheet;
700
+ uint8_t is_chartsheet;
671
701
 
672
702
  lxw_col_options **col_options;
673
703
  uint16_t col_options_max;
@@ -711,10 +741,10 @@ typedef struct lxw_worksheet {
711
741
  uint8_t right_to_left;
712
742
  uint8_t screen_gridlines;
713
743
  uint8_t show_zeros;
714
- uint8_t vba_codename;
715
744
  uint8_t vcenter;
716
745
  uint8_t zoom_scale_normal;
717
746
  uint8_t num_validations;
747
+ char *vba_codename;
718
748
 
719
749
  lxw_color_t tab_color;
720
750
 
@@ -1305,6 +1335,81 @@ lxw_error worksheet_write_formula_num(lxw_worksheet *worksheet,
1305
1335
  const char *formula,
1306
1336
  lxw_format *format, double result);
1307
1337
 
1338
+ /**
1339
+ * @brief Write a "Rich" multi-format string to a worksheet cell.
1340
+ *
1341
+ * @param worksheet pointer to a lxw_worksheet instance to be updated.
1342
+ * @param row The zero indexed row number.
1343
+ * @param col The zero indexed column number.
1344
+ * @param rich_string An array of format/string lxw_rich_string_tuple fragments.
1345
+ * @param format A pointer to a Format instance or NULL.
1346
+ *
1347
+ * @return A #lxw_error code.
1348
+ *
1349
+ * The `%worksheet_write_rich_string()` function is used to write strings with
1350
+ * multiple formats. For example to write the string 'This is **bold**
1351
+ * and this is *italic*' you would use the following:
1352
+ *
1353
+ * @code
1354
+ * lxw_format *bold = workbook_add_format(workbook);
1355
+ * format_set_bold(bold);
1356
+ *
1357
+ * lxw_format *italic = workbook_add_format(workbook);
1358
+ * format_set_italic(italic);
1359
+ *
1360
+ * lxw_rich_string_tuple fragment11 = {.format = NULL, .string = "This is " };
1361
+ * lxw_rich_string_tuple fragment12 = {.format = bold, .string = "bold" };
1362
+ * lxw_rich_string_tuple fragment13 = {.format = NULL, .string = " and this is "};
1363
+ * lxw_rich_string_tuple fragment14 = {.format = italic, .string = "italic" };
1364
+ *
1365
+ * lxw_rich_string_tuple *rich_string1[] = {&fragment11, &fragment12,
1366
+ * &fragment13, &fragment14, NULL};
1367
+ *
1368
+ * worksheet_write_rich_string(worksheet, CELL("A1"), rich_string1, NULL);
1369
+ *
1370
+ * @endcode
1371
+ *
1372
+ * @image html rich_strings_small.png
1373
+ *
1374
+ * The basic rule is to break the string into fragments and put a lxw_format
1375
+ * object before the fragment that you want to format. So if we look at the
1376
+ * above example again:
1377
+ *
1378
+ * This is **bold** and this is *italic*
1379
+ *
1380
+ * The would be broken down into 4 fragments:
1381
+ *
1382
+ * default: |This is |
1383
+ * bold: |bold|
1384
+ * default: | and this is |
1385
+ * italic: |italic|
1386
+ *
1387
+ * This in then converted to the lxw_rich_string_tuple fragments shown in the
1388
+ * example above. For the default format we use `NULL`.
1389
+ *
1390
+ * The fragments are passed to `%worksheet_write_rich_string()` as a `NULL`
1391
+ * terminated array:
1392
+ *
1393
+ * @code
1394
+ * lxw_rich_string_tuple *rich_string1[] = {&fragment11, &fragment12,
1395
+ * &fragment13, &fragment14, NULL};
1396
+ *
1397
+ * worksheet_write_rich_string(worksheet, CELL("A1"), rich_string1, NULL);
1398
+ *
1399
+ * @endcode
1400
+ *
1401
+ * **Note**:
1402
+ * Excel doesn't allow the use of two consecutive formats in a rich string or
1403
+ * an empty string fragment. For either of these conditions a warning is
1404
+ * raised and the input to `%worksheet_write_rich_string()` is ignored.
1405
+ *
1406
+ */
1407
+ lxw_error worksheet_write_rich_string(lxw_worksheet *worksheet,
1408
+ lxw_row_t row,
1409
+ lxw_col_t col,
1410
+ lxw_rich_string_tuple *rich_string[],
1411
+ lxw_format *format);
1412
+
1308
1413
  /**
1309
1414
  * @brief Set the properties for a row of cells.
1310
1415
  *
@@ -1487,7 +1592,7 @@ lxw_error worksheet_set_row_opt(lxw_worksheet *worksheet,
1487
1592
  * format_set_bold(bold);
1488
1593
  *
1489
1594
  * // Set the first column to bold.
1490
- * worksheet_set_column(worksheet, 0, 0, LXW_DEF_COL_HEIGHT, bold);
1595
+ * worksheet_set_column(worksheet, 0, 0, LXW_DEF_COL_WIDTH, bold);
1491
1596
  * @endcode
1492
1597
  *
1493
1598
  * The `format` parameter will be applied to any cells in the column that
@@ -1643,6 +1748,77 @@ lxw_error worksheet_insert_image_opt(lxw_worksheet *worksheet,
1643
1748
  lxw_row_t row, lxw_col_t col,
1644
1749
  const char *filename,
1645
1750
  lxw_image_options *options);
1751
+
1752
+ /**
1753
+ * @brief Insert an image in a worksheet cell, from a memory buffer.
1754
+ *
1755
+ * @param worksheet Pointer to a lxw_worksheet instance to be updated.
1756
+ * @param row The zero indexed row number.
1757
+ * @param col The zero indexed column number.
1758
+ * @param image_buffer Pointer to an array of bytes that holds the image data.
1759
+ * @param image_size The size of the array of bytes.
1760
+ *
1761
+ * @return A #lxw_error code.
1762
+ *
1763
+ * This function can be used to insert a image into a worksheet from a memory
1764
+ * buffer:
1765
+ *
1766
+ * @code
1767
+ * worksheet_insert_image_buffer(worksheet, CELL("B3"), image_buffer, image_size);
1768
+ * @endcode
1769
+ *
1770
+ * @image html image_buffer.png
1771
+ *
1772
+ * The buffer should be a pointer to an array of unsigned char data with a
1773
+ * specified size.
1774
+ *
1775
+ * See `worksheet_insert_image()` for details about the supported image
1776
+ * formats, and other image features.
1777
+ */
1778
+ lxw_error worksheet_insert_image_buffer(lxw_worksheet *worksheet,
1779
+ lxw_row_t row,
1780
+ lxw_col_t col,
1781
+ const unsigned char *image_buffer,
1782
+ size_t image_size);
1783
+
1784
+ /**
1785
+ * @brief Insert an image in a worksheet cell, from a memory buffer.
1786
+ *
1787
+ * @param worksheet Pointer to a lxw_worksheet instance to be updated.
1788
+ * @param row The zero indexed row number.
1789
+ * @param col The zero indexed column number.
1790
+ * @param image_buffer Pointer to an array of bytes that holds the image data.
1791
+ * @param image_size The size of the array of bytes.
1792
+ * @param options Optional image parameters.
1793
+ *
1794
+ * @return A #lxw_error code.
1795
+ *
1796
+ * The `%worksheet_insert_image_buffer_opt()` function is like
1797
+ * `worksheet_insert_image_buffer()` function except that it takes an optional
1798
+ * #lxw_image_options struct to scale and position the image:
1799
+ *
1800
+ * @code
1801
+ * lxw_image_options options = {.x_offset = 32, .y_offset = 4,
1802
+ * .x_scale = 2, .y_scale = 1};
1803
+ *
1804
+ * worksheet_insert_image_buffer_opt(worksheet, CELL("B3"), image_buffer, image_size, &options);
1805
+ * @endcode
1806
+ *
1807
+ * @image html image_buffer_opt.png
1808
+ *
1809
+ * The buffer should be a pointer to an array of unsigned char data with a
1810
+ * specified size.
1811
+ *
1812
+ * See `worksheet_insert_image_buffer_opt()` for details about the supported
1813
+ * image formats, and other image options.
1814
+ */
1815
+ lxw_error worksheet_insert_image_buffer_opt(lxw_worksheet *worksheet,
1816
+ lxw_row_t row,
1817
+ lxw_col_t col,
1818
+ const unsigned char *image_buffer,
1819
+ size_t image_size,
1820
+ lxw_image_options *options);
1821
+
1646
1822
  /**
1647
1823
  * @brief Insert a chart object into a worksheet.
1648
1824
  *
@@ -1653,8 +1829,8 @@ lxw_error worksheet_insert_image_opt(lxw_worksheet *worksheet,
1653
1829
  *
1654
1830
  * @return A #lxw_error code.
1655
1831
  *
1656
- * The `%worksheet_insert_chart()` can be used to insert a chart into a
1657
- * worksheet. The chart object must be created first using the
1832
+ * The `%worksheet_insert_chart()` function can be used to insert a chart into
1833
+ * a worksheet. The chart object must be created first using the
1658
1834
  * `workbook_add_chart()` function and configured using the @ref chart.h
1659
1835
  * functions.
1660
1836
  *
@@ -1665,13 +1841,12 @@ lxw_error worksheet_insert_image_opt(lxw_worksheet *worksheet,
1665
1841
  * // Add a data series to the chart.
1666
1842
  * chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$6");
1667
1843
  *
1668
- * // Insert the chart into the worksheet
1844
+ * // Insert the chart into the worksheet.
1669
1845
  * worksheet_insert_chart(worksheet, 0, 2, chart);
1670
1846
  * @endcode
1671
1847
  *
1672
1848
  * @image html chart_working.png
1673
1849
  *
1674
- *
1675
1850
  * **Note:**
1676
1851
  *
1677
1852
  * A chart may only be inserted into a worksheet once. If several similar
@@ -2282,26 +2457,26 @@ void worksheet_set_margins(lxw_worksheet *worksheet, double left,
2282
2457
  * @code
2283
2458
  * worksheet_set_header(worksheet, "&LHello");
2284
2459
  *
2285
- * ---------------------------------------------------------------
2286
- * | |
2287
- * | Hello |
2288
- * | |
2460
+ * // ---------------------------------------------------------------
2461
+ * // | |
2462
+ * // | Hello |
2463
+ * // | |
2289
2464
  *
2290
2465
  *
2291
2466
  * worksheet_set_header(worksheet, "&CHello");
2292
2467
  *
2293
- * ---------------------------------------------------------------
2294
- * | |
2295
- * | Hello |
2296
- * | |
2468
+ * // ---------------------------------------------------------------
2469
+ * // | |
2470
+ * // | Hello |
2471
+ * // | |
2297
2472
  *
2298
2473
  *
2299
2474
  * worksheet_set_header(worksheet, "&RHello");
2300
2475
  *
2301
- * ---------------------------------------------------------------
2302
- * | |
2303
- * | Hello |
2304
- * | |
2476
+ * // ---------------------------------------------------------------
2477
+ * // | |
2478
+ * // | Hello |
2479
+ * // | |
2305
2480
  *
2306
2481
  *
2307
2482
  * @endcode
@@ -2313,10 +2488,10 @@ void worksheet_set_margins(lxw_worksheet *worksheet, double left,
2313
2488
  * @code
2314
2489
  * worksheet_set_header(worksheet, "Hello");
2315
2490
  *
2316
- * ---------------------------------------------------------------
2317
- * | |
2318
- * | Hello |
2319
- * | |
2491
+ * // ---------------------------------------------------------------
2492
+ * // | |
2493
+ * // | Hello |
2494
+ * // | |
2320
2495
  *
2321
2496
  * @endcode
2322
2497
  *
@@ -2325,10 +2500,10 @@ void worksheet_set_margins(lxw_worksheet *worksheet, double left,
2325
2500
  * @code
2326
2501
  * worksheet_set_header(worksheet, "&LCiao&CBello&RCielo");
2327
2502
  *
2328
- * ---------------------------------------------------------------
2329
- * | |
2330
- * | Ciao Bello Cielo |
2331
- * | |
2503
+ * // ---------------------------------------------------------------
2504
+ * // | |
2505
+ * // | Ciao Bello Cielo |
2506
+ * // | |
2332
2507
  *
2333
2508
  * @endcode
2334
2509
  *
@@ -2339,17 +2514,17 @@ void worksheet_set_margins(lxw_worksheet *worksheet, double left,
2339
2514
  * @code
2340
2515
  * worksheet_set_header(worksheet, "&CPage &P of &N");
2341
2516
  *
2342
- * ---------------------------------------------------------------
2343
- * | |
2344
- * | Page 1 of 6 |
2345
- * | |
2517
+ * // ---------------------------------------------------------------
2518
+ * // | |
2519
+ * // | Page 1 of 6 |
2520
+ * // | |
2346
2521
  *
2347
2522
  * worksheet_set_header(worksheet, "&CUpdated at &T");
2348
2523
  *
2349
- * ---------------------------------------------------------------
2350
- * | |
2351
- * | Updated at 12:30 PM |
2352
- * | |
2524
+ * // ---------------------------------------------------------------
2525
+ * // | |
2526
+ * // | Updated at 12:30 PM |
2527
+ * // | |
2353
2528
  *
2354
2529
  * @endcode
2355
2530
  *
@@ -2889,8 +3064,8 @@ void worksheet_hide_zero(lxw_worksheet *worksheet);
2889
3064
  * @param worksheet Pointer to a lxw_worksheet instance to be updated.
2890
3065
  * @param color The tab color.
2891
3066
  *
2892
- * The `%worksheet_set_tab_color()` function is used to change the color of the worksheet
2893
- * tab:
3067
+ * The `%worksheet_set_tab_color()` function is used to change the color of
3068
+ * the worksheet tab:
2894
3069
  *
2895
3070
  * @code
2896
3071
  * worksheet_set_tab_color(worksheet1, LXW_COLOR_RED);
@@ -2973,11 +3148,10 @@ void worksheet_set_tab_color(lxw_worksheet *worksheet, lxw_color_t color);
2973
3148
  *
2974
3149
  * See also the format_set_unlocked() and format_set_hidden() format functions.
2975
3150
  *
2976
- * **Note:** Worksheet level passwords in Excel offer **very** weak
3151
+ * **Note:** Sheet level passwords in Excel offer **very** weak
2977
3152
  * protection. They don't encrypt your data and are very easy to
2978
3153
  * deactivate. Full workbook encryption is not supported by `libxlsxwriter`
2979
- * since it requires a completely different file format and would take several
2980
- * man months to implement.
3154
+ * since it requires a completely different file format.
2981
3155
  */
2982
3156
  void worksheet_protect(lxw_worksheet *worksheet, const char *password,
2983
3157
  lxw_protection *options);
@@ -3061,22 +3235,58 @@ void worksheet_outline_settings(lxw_worksheet *worksheet, uint8_t visible,
3061
3235
  void worksheet_set_default_row(lxw_worksheet *worksheet, double height,
3062
3236
  uint8_t hide_unused_rows);
3063
3237
 
3238
+ /**
3239
+ * @brief Set the VBA name for the worksheet.
3240
+ *
3241
+ * @param worksheet Pointer to a lxw_worksheet instance.
3242
+ * @param name Name of the worksheet used by VBA.
3243
+ *
3244
+ * The `worksheet_set_vba_name()` function can be used to set the VBA name for
3245
+ * the worksheet. This is sometimes required when a vbaProject macro included
3246
+ * via `workbook_add_vba_project()` refers to the worksheet.
3247
+ *
3248
+ * @code
3249
+ * workbook_set_vba_name (workbook, "MyWorkbook");
3250
+ * worksheet_set_vba_name(worksheet, "MySheet1");
3251
+ * @endcode
3252
+ *
3253
+ * In general Excel uses the worksheet name such as "Sheet1" as the VBA name.
3254
+ * However, this can be changed in the VBA environment or if the the macro was
3255
+ * extracted from a foreign language version of Excel.
3256
+ *
3257
+ * @return A #lxw_error.
3258
+ */
3259
+ lxw_error worksheet_set_vba_name(lxw_worksheet *worksheet, const char *name);
3260
+
3064
3261
  lxw_worksheet *lxw_worksheet_new(lxw_worksheet_init_data *init_data);
3065
3262
  void lxw_worksheet_free(lxw_worksheet *worksheet);
3066
3263
  void lxw_worksheet_assemble_xml_file(lxw_worksheet *worksheet);
3067
3264
  void lxw_worksheet_write_single_row(lxw_worksheet *worksheet);
3068
3265
 
3069
3266
  void lxw_worksheet_prepare_image(lxw_worksheet *worksheet,
3070
- uint16_t image_ref_id, uint16_t drawing_id,
3267
+ uint32_t image_ref_id, uint32_t drawing_id,
3071
3268
  lxw_image_options *image_data);
3072
3269
 
3073
3270
  void lxw_worksheet_prepare_chart(lxw_worksheet *worksheet,
3074
- uint16_t chart_ref_id, uint16_t drawing_id,
3075
- lxw_image_options *image_data);
3271
+ uint32_t chart_ref_id, uint32_t drawing_id,
3272
+ lxw_image_options *image_data,
3273
+ uint8_t is_chartsheet);
3076
3274
 
3077
3275
  lxw_row *lxw_worksheet_find_row(lxw_worksheet *worksheet, lxw_row_t row_num);
3078
3276
  lxw_cell *lxw_worksheet_find_cell(lxw_row *row, lxw_col_t col_num);
3079
3277
 
3278
+ /*
3279
+ * External functions to call intern XML methods shared with chartsheet.
3280
+ */
3281
+ void lxw_worksheet_write_sheet_views(lxw_worksheet *worksheet);
3282
+ void lxw_worksheet_write_page_margins(lxw_worksheet *worksheet);
3283
+ void lxw_worksheet_write_drawings(lxw_worksheet *worksheet);
3284
+ void lxw_worksheet_write_sheet_protection(lxw_worksheet *worksheet,
3285
+ lxw_protection *protect);
3286
+ void lxw_worksheet_write_sheet_pr(lxw_worksheet *worksheet);
3287
+ void lxw_worksheet_write_page_setup(lxw_worksheet *worksheet);
3288
+ void lxw_worksheet_write_header_footer(lxw_worksheet *worksheet);
3289
+
3080
3290
  /* Declarations required for unit testing. */
3081
3291
  #ifdef TESTING
3082
3292
 
@@ -3106,7 +3316,8 @@ STATIC void _worksheet_write_header_footer(lxw_worksheet *worksheet);
3106
3316
  STATIC void _worksheet_write_print_options(lxw_worksheet *worksheet);
3107
3317
  STATIC void _worksheet_write_sheet_pr(lxw_worksheet *worksheet);
3108
3318
  STATIC void _worksheet_write_tab_color(lxw_worksheet *worksheet);
3109
- STATIC void _worksheet_write_sheet_protection(lxw_worksheet *worksheet);
3319
+ STATIC void _worksheet_write_sheet_protection(lxw_worksheet *worksheet,
3320
+ lxw_protection *protect);
3110
3321
  STATIC void _worksheet_write_data_validations(lxw_worksheet *self);
3111
3322
  #endif /* TESTING */
3112
3323