xlsxwriter 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87c37e7b981c1632bac997c8d660435d17a8240863fbb0878b682b5ebd2a6f1b
4
- data.tar.gz: 1dbfe32328dd2a7a4728982061539fed19b78cd8408ffbeda18e1021cc2b1dbe
3
+ metadata.gz: c4803495a8461935936f93daa7b11167935d977415e3a64279ace94a15a9ee55
4
+ data.tar.gz: 7c9b3293a7166a11739bb1ec794a852248914fcac8d5f759058b035c6a0f4e84
5
5
  SHA512:
6
- metadata.gz: f7931484a9239a3cfea028e212d79fa51f67cadcc377d5c7f06337f408add6446a3b988b5018510d2a92a33062525bf2294b992a385843755d9307581810c89b
7
- data.tar.gz: 3ff9f83786a755d0ce8c5a02418da3931f0f7a9d8fe808594b7ee2bba42eedbe77d09ca691f20f0db8f96e5f8d049a1fd0c0041278436aac07c79bbad932caf1
6
+ metadata.gz: 6dd4d9ab1eb21b5b2eb2f92d8f5b6d7753af94ad85dfeadbff8dad24f0c7c2ca7a3791762bed349560f3165226c47f573020f5318173232a9d16644aa1346a72
7
+ data.tar.gz: 18730b942a2015143aceb297014755da8465a6db55b51033e97a73f2d57f335efd2c4fafceb3b665ea0797b1df6bdcf11eb373ef6e330025943e7414281bfb19
@@ -18,6 +18,6 @@
18
18
  #include "xlsxwriter/format.h"
19
19
  #include "xlsxwriter/utility.h"
20
20
 
21
- #define LXW_VERSION "0.8.5"
21
+ #define LXW_VERSION "0.8.6"
22
22
 
23
23
  #endif /* __LXW_XLSXWRITER_H__ */
@@ -55,9 +55,6 @@ typedef struct lxw_packager {
55
55
  char *buffer;
56
56
  char *tmpdir;
57
57
 
58
- uint16_t chart_count;
59
- uint16_t drawing_count;
60
-
61
58
  } lxw_packager;
62
59
 
63
60
 
@@ -454,7 +454,7 @@ format_set_rotation(lxw_format *self, int16_t angle)
454
454
  if (angle == 270) {
455
455
  self->rotation = 255;
456
456
  }
457
- else if (angle >= -90 || angle <= 90) {
457
+ else if (angle >= -90 && angle <= 90) {
458
458
  if (angle < 0)
459
459
  angle = -angle + 90;
460
460
 
@@ -319,14 +319,29 @@ _write_chart_files(lxw_packager *self)
319
319
  err = _add_file_to_zip(self, chart->file, sheetname);
320
320
  RETURN_ON_ERROR(err);
321
321
 
322
- self->chart_count++;
323
-
324
322
  fclose(chart->file);
325
323
  }
326
324
 
327
325
  return LXW_NO_ERROR;
328
326
  }
329
327
 
328
+ /*
329
+ * Count the chart files.
330
+ */
331
+ uint16_t
332
+ _get_chart_count(lxw_packager *self)
333
+ {
334
+ lxw_workbook *workbook = self->workbook;
335
+ lxw_chart *chart;
336
+ uint16_t chart_count = 0;
337
+
338
+ STAILQ_FOREACH(chart, workbook->ordered_charts, ordered_list_pointers) {
339
+ chart_count++;
340
+ }
341
+
342
+ return chart_count;
343
+ }
344
+
330
345
  /*
331
346
  * Write the drawing files.
332
347
  */
@@ -362,14 +377,39 @@ _write_drawing_files(lxw_packager *self)
362
377
  RETURN_ON_ERROR(err);
363
378
 
364
379
  fclose(drawing->file);
365
-
366
- self->drawing_count++;
367
380
  }
368
381
  }
369
382
 
370
383
  return LXW_NO_ERROR;
371
384
  }
372
385
 
386
+ /*
387
+ * Count the drawing files.
388
+ */
389
+ uint16_t
390
+ _get_drawing_count(lxw_packager *self)
391
+ {
392
+ lxw_workbook *workbook = self->workbook;
393
+ lxw_sheet *sheet;
394
+ lxw_worksheet *worksheet;
395
+ lxw_drawing *drawing;
396
+ uint16_t drawing_count = 0;
397
+
398
+ STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
399
+ if (sheet->is_chartsheet)
400
+ worksheet = sheet->u.chartsheet->worksheet;
401
+ else
402
+ worksheet = sheet->u.worksheet;
403
+
404
+ drawing = worksheet->drawing;
405
+
406
+ if (drawing)
407
+ drawing_count++;
408
+ }
409
+
410
+ return drawing_count;
411
+ }
412
+
373
413
  /*
374
414
  * Write the sharedStrings.xml file.
375
415
  */
@@ -657,6 +697,8 @@ _write_content_types_file(lxw_packager *self)
657
697
  uint16_t index = 1;
658
698
  uint16_t worksheet_index = 1;
659
699
  uint16_t chartsheet_index = 1;
700
+ uint16_t drawing_count = _get_drawing_count(self);
701
+ uint16_t chart_count = _get_chart_count(self);
660
702
  lxw_error err = LXW_NO_ERROR;
661
703
 
662
704
  if (!content_types) {
@@ -692,13 +734,13 @@ _write_content_types_file(lxw_packager *self)
692
734
  }
693
735
  }
694
736
 
695
- for (index = 1; index <= self->chart_count; index++) {
737
+ for (index = 1; index <= chart_count; index++) {
696
738
  lxw_snprintf(filename, LXW_FILENAME_LENGTH, "/xl/charts/chart%d.xml",
697
739
  index);
698
740
  lxw_ct_add_chart_name(content_types, filename);
699
741
  }
700
742
 
701
- for (index = 1; index <= self->drawing_count; index++) {
743
+ for (index = 1; index <= drawing_count; index++) {
702
744
  lxw_snprintf(filename, LXW_FILENAME_LENGTH,
703
745
  "/xl/drawings/drawing%d.xml", index);
704
746
  lxw_ct_add_drawing_name(content_types, filename);
@@ -1056,16 +1098,11 @@ _add_file_to_zip(lxw_packager *self, FILE * file, const char *filename)
1056
1098
  size_read = fread(self->buffer, 1, self->buffer_size, file);
1057
1099
  }
1058
1100
 
1059
- if (error < 0) {
1101
+ error = zipCloseFileInZip(self->zipfile);
1102
+ if (error != ZIP_OK) {
1103
+ LXW_ERROR("Error in closing member in the zipfile");
1060
1104
  RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
1061
1105
  }
1062
- else {
1063
- error = zipCloseFileInZip(self->zipfile);
1064
- if (error != ZIP_OK) {
1065
- LXW_ERROR("Error in closing member in the zipfile");
1066
- RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
1067
- }
1068
- }
1069
1106
 
1070
1107
  return LXW_NO_ERROR;
1071
1108
  }
@@ -1097,16 +1134,11 @@ _add_buffer_to_zip(lxw_packager *self, unsigned char *buffer,
1097
1134
  RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
1098
1135
  }
1099
1136
 
1100
- if (error < 0) {
1137
+ error = zipCloseFileInZip(self->zipfile);
1138
+ if (error != ZIP_OK) {
1139
+ LXW_ERROR("Error in closing member in the zipfile");
1101
1140
  RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
1102
1141
  }
1103
- else {
1104
- error = zipCloseFileInZip(self->zipfile);
1105
- if (error != ZIP_OK) {
1106
- LXW_ERROR("Error in closing member in the zipfile");
1107
- RETURN_ON_ZIP_ERROR(error, LXW_ERROR_ZIP_FILE_ADD);
1108
- }
1109
- }
1110
1142
 
1111
1143
  return LXW_NO_ERROR;
1112
1144
  }
@@ -1120,6 +1152,15 @@ lxw_create_package(lxw_packager *self)
1120
1152
  lxw_error error;
1121
1153
  int8_t zip_error;
1122
1154
 
1155
+ error = _write_content_types_file(self);
1156
+ RETURN_ON_ERROR(error);
1157
+
1158
+ error = _write_root_rels_file(self);
1159
+ RETURN_ON_ERROR(error);
1160
+
1161
+ error = _write_workbook_rels_file(self);
1162
+ RETURN_ON_ERROR(error);
1163
+
1123
1164
  error = _write_worksheet_files(self);
1124
1165
  RETURN_ON_ERROR(error);
1125
1166
 
@@ -1138,12 +1179,6 @@ lxw_create_package(lxw_packager *self)
1138
1179
  error = _write_shared_strings_file(self);
1139
1180
  RETURN_ON_ERROR(error);
1140
1181
 
1141
- error = _write_app_file(self);
1142
- RETURN_ON_ERROR(error);
1143
-
1144
- error = _write_core_file(self);
1145
- RETURN_ON_ERROR(error);
1146
-
1147
1182
  error = _write_custom_file(self);
1148
1183
  RETURN_ON_ERROR(error);
1149
1184
 
@@ -1153,12 +1188,6 @@ lxw_create_package(lxw_packager *self)
1153
1188
  error = _write_styles_file(self);
1154
1189
  RETURN_ON_ERROR(error);
1155
1190
 
1156
- error = _write_content_types_file(self);
1157
- RETURN_ON_ERROR(error);
1158
-
1159
- error = _write_workbook_rels_file(self);
1160
- RETURN_ON_ERROR(error);
1161
-
1162
1191
  error = _write_worksheet_rels_file(self);
1163
1192
  RETURN_ON_ERROR(error);
1164
1193
 
@@ -1171,7 +1200,10 @@ lxw_create_package(lxw_packager *self)
1171
1200
  error = _write_image_files(self);
1172
1201
  RETURN_ON_ERROR(error);
1173
1202
 
1174
- error = _write_root_rels_file(self);
1203
+ error = _write_core_file(self);
1204
+ RETURN_ON_ERROR(error);
1205
+
1206
+ error = _write_app_file(self);
1175
1207
  RETURN_ON_ERROR(error);
1176
1208
 
1177
1209
  zip_error = zipClose(self->zipfile, NULL);
@@ -1740,6 +1740,9 @@ _worksheet_size_col(lxw_worksheet *self, lxw_col_t col_num)
1740
1740
  }
1741
1741
 
1742
1742
  if (col_opt) {
1743
+ if (col_opt->hidden)
1744
+ return 0;
1745
+
1743
1746
  width = col_opt->width;
1744
1747
 
1745
1748
  /* Convert to pixels. */
@@ -1775,6 +1778,9 @@ _worksheet_size_row(lxw_worksheet *self, lxw_row_t row_num)
1775
1778
  row = lxw_worksheet_find_row(self, row_num);
1776
1779
 
1777
1780
  if (row) {
1781
+ if (row->hidden)
1782
+ return 0;
1783
+
1778
1784
  height = row->height;
1779
1785
 
1780
1786
  if (height == 0)
@@ -1901,23 +1907,30 @@ _worksheet_position_object_pixels(lxw_worksheet *self,
1901
1907
  y_abs += y1;
1902
1908
 
1903
1909
  /* Adjust start col for offsets that are greater than the col width. */
1904
- while (x1 >= _worksheet_size_col(self, col_start)) {
1905
- x1 -= _worksheet_size_col(self, col_start);
1906
- col_start++;
1910
+ if (_worksheet_size_col(self, col_start) > 0) {
1911
+ while (x1 >= _worksheet_size_col(self, col_start)) {
1912
+ x1 -= _worksheet_size_col(self, col_start);
1913
+ col_start++;
1914
+ }
1907
1915
  }
1908
1916
 
1909
1917
  /* Adjust start row for offsets that are greater than the row height. */
1910
- while (y1 >= _worksheet_size_row(self, row_start)) {
1911
- y1 -= _worksheet_size_row(self, row_start);
1912
- row_start++;
1918
+ if (_worksheet_size_row(self, row_start) > 0) {
1919
+ while (y1 >= _worksheet_size_row(self, row_start)) {
1920
+ y1 -= _worksheet_size_row(self, row_start);
1921
+ row_start++;
1922
+ }
1913
1923
  }
1914
1924
 
1915
1925
  /* Initialize end cell to the same as the start cell. */
1916
1926
  col_end = col_start;
1917
1927
  row_end = row_start;
1918
1928
 
1919
- width = width + x1;
1920
- height = height + y1;
1929
+ /* Only offset the image in the cell if the row/col isn't hidden. */
1930
+ if (_worksheet_size_col(self, col_start) > 0)
1931
+ width = width + x1;
1932
+ if (_worksheet_size_row(self, row_start) > 0)
1933
+ height = height + y1;
1921
1934
 
1922
1935
  /* Subtract the underlying cell widths to find the end cell. */
1923
1936
  while (width >= _worksheet_size_col(self, col_end)) {
@@ -2,5 +2,5 @@
2
2
 
3
3
  module XlsxWriter
4
4
  # :nodoc:
5
- VERSION='0.1.0'.freeze
5
+ VERSION='0.1.1'.freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsxwriter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick H
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-19 00:00:00.000000000 Z
11
+ date: 2019-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
201
  requirements: []
202
- rubygems_version: 3.0.1
202
+ rubygems_version: 3.0.3
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Ruby interface to libxlsxwriter