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 +4 -4
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +0 -3
- data/ext/xlsxwriter/libxlsxwriter/src/format.c +1 -1
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +67 -35
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +21 -8
- data/lib/xlsxwriter/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4803495a8461935936f93daa7b11167935d977415e3a64279ace94a15a9ee55
|
4
|
+
data.tar.gz: 7c9b3293a7166a11739bb1ec794a852248914fcac8d5f759058b035c6a0f4e84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dd4d9ab1eb21b5b2eb2f92d8f5b6d7753af94ad85dfeadbff8dad24f0c7c2ca7a3791762bed349560f3165226c47f573020f5318173232a9d16644aa1346a72
|
7
|
+
data.tar.gz: 18730b942a2015143aceb297014755da8465a6db55b51033e97a73f2d57f335efd2c4fafceb3b665ea0797b1df6bdcf11eb373ef6e330025943e7414281bfb19
|
@@ -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 <=
|
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 <=
|
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
|
-
|
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
|
-
|
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 =
|
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
|
-
|
1905
|
-
x1
|
1906
|
-
|
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
|
-
|
1911
|
-
y1
|
1912
|
-
|
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
|
-
|
1920
|
-
|
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)) {
|
data/lib/xlsxwriter/version.rb
CHANGED
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.
|
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-
|
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.
|
202
|
+
rubygems_version: 3.0.3
|
203
203
|
signing_key:
|
204
204
|
specification_version: 4
|
205
205
|
summary: Ruby interface to libxlsxwriter
|