kmadej_fast_excel_fork 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +28 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +70 -0
- data/Makefile +14 -0
- data/README.md +95 -0
- data/Rakefile +24 -0
- data/appveyor.yml +25 -0
- data/benchmarks/1k_rows.rb +59 -0
- data/benchmarks/20k_rows.rb +26 -0
- data/benchmarks/init.rb +59 -0
- data/benchmarks/memory.rb +49 -0
- data/examples/example.rb +42 -0
- data/examples/example_align.rb +23 -0
- data/examples/example_chart.rb +21 -0
- data/examples/example_colors.rb +37 -0
- data/examples/example_formula.rb +18 -0
- data/examples/example_image.rb +13 -0
- data/examples/example_styles.rb +27 -0
- data/examples/logo.png +0 -0
- data/extconf.rb +0 -0
- data/fast_excel.gemspec +20 -0
- data/lib/fast_excel.rb +600 -0
- data/lib/fast_excel/binding.rb +2819 -0
- data/lib/fast_excel/binding/chart.rb +2666 -0
- data/lib/fast_excel/binding/format.rb +1177 -0
- data/lib/fast_excel/binding/workbook.rb +338 -0
- data/lib/fast_excel/binding/worksheet.rb +1555 -0
- data/libxlsxwriter/.gitignore +49 -0
- data/libxlsxwriter/.indent.pro +125 -0
- data/libxlsxwriter/.travis.yml +25 -0
- data/libxlsxwriter/CONTRIBUTING.md +226 -0
- data/libxlsxwriter/Changes.txt +557 -0
- data/libxlsxwriter/LICENSE.txt +89 -0
- data/libxlsxwriter/Makefile +156 -0
- data/libxlsxwriter/Readme.md +78 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +30 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter.modulemap +7 -0
- data/libxlsxwriter/include/xlsxwriter.h +23 -0
- data/libxlsxwriter/include/xlsxwriter/app.h +79 -0
- data/libxlsxwriter/include/xlsxwriter/chart.h +3476 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +372 -0
- data/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
- data/libxlsxwriter/include/xlsxwriter/core.h +51 -0
- data/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
- data/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
- data/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
- data/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
- data/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
- data/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
- data/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +214 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
- data/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
- data/libxlsxwriter/include/xlsxwriter/workbook.h +757 -0
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
- data/libxlsxwriter/lib/.gitignore +0 -0
- data/libxlsxwriter/libxlsxwriter.podspec +47 -0
- data/libxlsxwriter/src/Makefile +130 -0
- data/libxlsxwriter/src/app.c +443 -0
- data/libxlsxwriter/src/chart.c +6346 -0
- data/libxlsxwriter/src/content_types.c +345 -0
- data/libxlsxwriter/src/core.c +293 -0
- data/libxlsxwriter/src/custom.c +224 -0
- data/libxlsxwriter/src/drawing.c +746 -0
- data/libxlsxwriter/src/format.c +729 -0
- data/libxlsxwriter/src/hash_table.c +223 -0
- data/libxlsxwriter/src/packager.c +948 -0
- data/libxlsxwriter/src/relationships.c +245 -0
- data/libxlsxwriter/src/shared_strings.c +266 -0
- data/libxlsxwriter/src/styles.c +1088 -0
- data/libxlsxwriter/src/theme.c +348 -0
- data/libxlsxwriter/src/utility.c +515 -0
- data/libxlsxwriter/src/workbook.c +1930 -0
- data/libxlsxwriter/src/worksheet.c +5022 -0
- data/libxlsxwriter/src/xmlwriter.c +355 -0
- data/libxlsxwriter/third_party/minizip/Makefile +44 -0
- data/libxlsxwriter/third_party/minizip/Makefile.am +45 -0
- data/libxlsxwriter/third_party/minizip/Makefile.orig +25 -0
- data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +6 -0
- data/libxlsxwriter/third_party/minizip/MiniZip64_info.txt +74 -0
- data/libxlsxwriter/third_party/minizip/README.txt +5 -0
- data/libxlsxwriter/third_party/minizip/configure.ac +32 -0
- data/libxlsxwriter/third_party/minizip/crypt.h +131 -0
- data/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
- data/libxlsxwriter/third_party/minizip/ioapi.h +208 -0
- data/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
- data/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
- data/libxlsxwriter/third_party/minizip/make_vms.com +25 -0
- data/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
- data/libxlsxwriter/third_party/minizip/miniunzip.1 +63 -0
- data/libxlsxwriter/third_party/minizip/minizip.1 +46 -0
- data/libxlsxwriter/third_party/minizip/minizip.c +520 -0
- data/libxlsxwriter/third_party/minizip/minizip.pc.in +12 -0
- data/libxlsxwriter/third_party/minizip/mztools.c +291 -0
- data/libxlsxwriter/third_party/minizip/mztools.h +37 -0
- data/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
- data/libxlsxwriter/third_party/minizip/unzip.h +437 -0
- data/libxlsxwriter/third_party/minizip/zip.c +2007 -0
- data/libxlsxwriter/third_party/minizip/zip.h +367 -0
- data/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
- data/libxlsxwriter/version.txt +1 -0
- data/test/date_test.rb +22 -0
- data/test/default_format_test.rb +19 -0
- data/test/format_test.rb +171 -0
- data/test/test_helper.rb +52 -0
- data/test/tmpfile_test.rb +23 -0
- data/test/worksheet_test.rb +86 -0
- metadata +182 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
/* $Id: tmpfileplus.h $ */
|
2
|
+
/*
|
3
|
+
* $Date: 2016-06-01 03:31Z $
|
4
|
+
* $Revision: 2.0.0 $
|
5
|
+
* $Author: dai $
|
6
|
+
*/
|
7
|
+
|
8
|
+
/*
|
9
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
10
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
11
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
12
|
+
*
|
13
|
+
* Copyright (c) 2012-16 David Ireland, DI Management Services Pty Ltd
|
14
|
+
* <http://www.di-mgt.com.au/contact/>.
|
15
|
+
*/
|
16
|
+
|
17
|
+
#if _MSC_VER > 1000
|
18
|
+
#pragma once
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#ifndef TMPFILEPLUS_H_
|
22
|
+
#define TMPFILEPLUS_H_
|
23
|
+
|
24
|
+
#include <stdio.h>
|
25
|
+
|
26
|
+
/** Create a unique temporary file.
|
27
|
+
@param dir (optional) directory to create file. If NULL use default TMP directory.
|
28
|
+
@param prefix (optional) prefix for file name. If NULL use "tmp.".
|
29
|
+
@param pathname (optional) pointer to a buffer to receive the temp filename.
|
30
|
+
Allocated using `malloc()`; user to free. Ignored if NULL.
|
31
|
+
@param keep If `keep` is nonzero and `pathname` is not NULL, then keep the file after closing.
|
32
|
+
Otherwise file is automatically deleted when closed.
|
33
|
+
@return Pointer to stream opened in binary read/write (w+b) mode, or a null pointer on error.
|
34
|
+
@exception ENOMEM Not enough memory to allocate filename.
|
35
|
+
*/
|
36
|
+
FILE *tmpfileplus(const char *dir, const char *prefix, char **pathname, int keep);
|
37
|
+
|
38
|
+
|
39
|
+
/** Create a unique temporary file with filename stored in a fixed-length buffer.
|
40
|
+
@param dir (optional) directory to create file. If NULL use default directory.
|
41
|
+
@param prefix (optional) prefix for file name. If NULL use "tmp.".
|
42
|
+
@param pathnamebuf (optional) buffer to receive full pathname of temporary file. Ignored if NULL.
|
43
|
+
@param pathsize Size of buffer to receive filename and its terminating null character.
|
44
|
+
@param keep If `keep` is nonzero and `pathname` is not NULL, then keep the file after closing.
|
45
|
+
Otherwise file is automatically deleted when closed.
|
46
|
+
@return Pointer to stream opened in binary read/write (w+b) mode, or a null pointer on error.
|
47
|
+
@exception E2BIG Resulting filename is too big for the buffer `pathnamebuf`.
|
48
|
+
*/
|
49
|
+
FILE *tmpfileplus_f(const char *dir, const char *prefix, char *pathnamebuf, size_t pathsize, int keep);
|
50
|
+
|
51
|
+
#define TMPFILE_KEEP 1
|
52
|
+
|
53
|
+
#endif /* end TMPFILEPLUS_H_ */
|
@@ -0,0 +1 @@
|
|
1
|
+
2017-02-28 20:35:27 +0800 c8064ee
|
data/test/date_test.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "FastExcel.date_num" do
|
4
|
+
|
5
|
+
it "should save correct date" do
|
6
|
+
workbook = FastExcel.open("test.xlsx", constant_memory: true)
|
7
|
+
worksheet = workbook.add_worksheet("Payments Report")
|
8
|
+
|
9
|
+
date_format = workbook.number_format("[$-409]m/d/yy h:mm AM/PM;@")
|
10
|
+
worksheet.set_column(0, 0, 20, date_format)
|
11
|
+
|
12
|
+
date = DateTime.parse('2017-03-01 15:15:15 +0000').to_time
|
13
|
+
|
14
|
+
worksheet.write_number(0, 0, FastExcel.date_num(date), nil)
|
15
|
+
workbook.close
|
16
|
+
|
17
|
+
data = parse_xlsx_as_matrix("test.xlsx")
|
18
|
+
|
19
|
+
assert_equal(data[0][0].to_time, date)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "FastExcel default_format" do
|
4
|
+
|
5
|
+
it "should set default format values on init" do
|
6
|
+
workbook = FastExcel.open(default_format: {
|
7
|
+
font_size: 17,
|
8
|
+
font_family: "ArialFoo",
|
9
|
+
bold: true
|
10
|
+
})
|
11
|
+
|
12
|
+
#FastExcel.print_ffi_obj(workbook.default_format)
|
13
|
+
|
14
|
+
assert_equal("ArialFoo", workbook.default_format.font_family)
|
15
|
+
assert_equal(17, workbook.default_format.font_size)
|
16
|
+
assert_equal(1, workbook.default_format.bold)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/test/format_test.rb
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "FastExcel::FormatExt align" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@workbook = FastExcel.open(constant_memory: true)
|
7
|
+
@format = @workbook.add_format
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should give default aligns" do
|
11
|
+
assert_equal({horizontal: :align_none, vertical: :align_none}, @format.align)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should set align by full name" do
|
15
|
+
@format.align = :align_center
|
16
|
+
assert_equal({horizontal: :align_center, vertical: :align_none}, @format.align)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should set by string" do
|
20
|
+
@format.align = "align_center"
|
21
|
+
assert_equal({horizontal: :align_center, vertical: :align_none}, @format.align)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should set by short name" do
|
25
|
+
@format.align = :center
|
26
|
+
assert_equal({horizontal: :align_center, vertical: :align_none}, @format.align)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should set by hash" do
|
30
|
+
@format.align = {v: "center", h: "center"}
|
31
|
+
assert_equal({horizontal: :align_center, vertical: :align_vertical_center}, @format.align)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should raise exception for unknown value" do
|
35
|
+
error = assert_raises(ArgumentError) do
|
36
|
+
@format.align = :aaa
|
37
|
+
end
|
38
|
+
|
39
|
+
assert_equal(error.message, "Can not set align = :aaa, possible values are: [:align_none, :align_left, "\
|
40
|
+
":align_center, :align_right, :align_fill, :align_justify, :align_center_across, :align_distributed, "\
|
41
|
+
":align_vertical_top, :align_vertical_bottom, :align_vertical_center, :align_vertical_justify, :align_vertical_distributed]")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should raise exception for unknown hash key" do
|
45
|
+
error = assert_raises(ArgumentError) do
|
46
|
+
@format.align = {aaa: 1}
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_equal(error.message, "Not allowed keys for align: [:aaa], possible keys: [:horizontal, :h, :vertical, :v]")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should get and set" do
|
53
|
+
@format.align = {h: :center, v: :center}
|
54
|
+
format2 = @workbook.add_format(align: @format.align)
|
55
|
+
|
56
|
+
assert_equal({horizontal: :align_center, vertical: :align_vertical_center}, format2.align)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
describe "FastExcel::FormatExt colors" do
|
63
|
+
|
64
|
+
before do
|
65
|
+
workbook = FastExcel.open(constant_memory: true)
|
66
|
+
@format = workbook.add_format
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should set font color as hex num" do
|
70
|
+
@format.font_color = 0xFF0000
|
71
|
+
assert_equal(0xFF0000, @format.font_color)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should set font color as hex string" do
|
75
|
+
@format.font_color = '0xFF0000'
|
76
|
+
assert_equal(0xFF0000, @format.font_color)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should set font color as css hex string" do
|
80
|
+
@format.font_color = '#FF0000'
|
81
|
+
assert_equal(0xFF0000, @format.font_color)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should set font color as short hex string" do
|
85
|
+
@format.font_color = 'FF0000'
|
86
|
+
assert_equal(0xFF0000, @format.font_color)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should set font color as name" do
|
90
|
+
@format.font_color = 'red'
|
91
|
+
assert_equal(0xFF0000, @format.font_color)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should set font css color" do
|
95
|
+
@format.font_color = 'alice_blue'
|
96
|
+
assert_equal(0xF0F8FF, @format.font_color)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should allow to use symbol" do
|
100
|
+
@format.font_color = :alice_blue
|
101
|
+
assert_equal(0xF0F8FF, @format.font_color)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should have long method for border colors" do
|
105
|
+
@format.border_bottom_color = :alice_blue
|
106
|
+
assert_equal(0xF0F8FF, @format.border_bottom_color)
|
107
|
+
assert_equal(0xF0F8FF, @format.bottom_color)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should raise for unexpected type" do
|
111
|
+
error = assert_raises(ArgumentError) do
|
112
|
+
@format.font_color = {aaa: 1}
|
113
|
+
end
|
114
|
+
|
115
|
+
assert_equal(error.message, "Can not use Hash ({:aaa=>1}) for color value, expected String or Hex Number")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should raise for unexpected color" do
|
119
|
+
error = assert_raises(ArgumentError) do
|
120
|
+
@format.font_color = :aaa
|
121
|
+
end
|
122
|
+
|
123
|
+
assert_equal(error.message, "Unknown color value :aaa, expected hex string or color name")
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
describe "FastExcel::FormatExt border" do
|
130
|
+
|
131
|
+
before do
|
132
|
+
workbook = FastExcel.open(constant_memory: true)
|
133
|
+
@format = workbook.add_format
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should set border as symbol" do
|
137
|
+
@format.bottom = :border_thin
|
138
|
+
assert_equal(:border_thin, @format.bottom)
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should set border as short symbol" do
|
142
|
+
@format.bottom = :thin
|
143
|
+
assert_equal(:border_thin, @format.bottom)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should set border as string" do
|
147
|
+
@format.bottom = "thin"
|
148
|
+
assert_equal(:border_thin, @format.bottom)
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should set border as number" do
|
152
|
+
@format.bottom = 1
|
153
|
+
assert_equal(:border_thin, @format.bottom)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should set border with long prop name" do
|
157
|
+
error = assert_raises(ArgumentError) do
|
158
|
+
@format.border_bottom = :aaa
|
159
|
+
end
|
160
|
+
|
161
|
+
assert_equal(error.message, "Unknown value :aaa for border. Possible values: "\
|
162
|
+
"[:none, :thin, :medium, :dashed, :dotted, :thick, :double, :hair, :medium_dashed, "\
|
163
|
+
":dash_dot, :medium_dash_dot, :dash_dot_dot, :medium_dash_dot_dot, :slant_dash_dot]")
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should get value with long name" do
|
167
|
+
@format.bottom = "thin"
|
168
|
+
assert_equal(:border_thin, @format.border_bottom)
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require "minitest/reporters"
|
4
|
+
|
5
|
+
##Encoding.default_external = Encoding::UTF_8
|
6
|
+
##Encoding.default_internal = Encoding::UTF_8
|
7
|
+
|
8
|
+
require 'date'
|
9
|
+
|
10
|
+
Minitest::Reporters.use!(
|
11
|
+
Minitest::Reporters::DefaultReporter.new(color: true)
|
12
|
+
)
|
13
|
+
|
14
|
+
require_relative '../lib/fast_excel'
|
15
|
+
|
16
|
+
def parse_xlsx(file_path)
|
17
|
+
require 'roo'
|
18
|
+
Roo::Excelx.new(file_path)
|
19
|
+
ensure
|
20
|
+
File.delete(file_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_arrays(workbook)
|
24
|
+
workbook.close
|
25
|
+
parse_xlsx_as_matrix(workbook.filename)
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_xlsx_as_array(file_path)
|
29
|
+
data = parse_xlsx_as_matrix(file_path)
|
30
|
+
headers = data.shift
|
31
|
+
|
32
|
+
data.map do |row|
|
33
|
+
Hash[ [headers, row].transpose ]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse_xlsx_as_matrix(file_path)
|
38
|
+
excel = parse_xlsx(file_path)
|
39
|
+
|
40
|
+
sheet = excel.sheet(0)
|
41
|
+
|
42
|
+
rows = []
|
43
|
+
1.upto(sheet.last_row) do |row_number|
|
44
|
+
row = 1.upto(sheet.last_column).map do |col|
|
45
|
+
sheet.cell(row_number, col)
|
46
|
+
end
|
47
|
+
|
48
|
+
rows << row
|
49
|
+
end
|
50
|
+
|
51
|
+
return rows
|
52
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "FastExcel" do
|
4
|
+
|
5
|
+
it "should create temporary file if filename is nil" do
|
6
|
+
workbook = FastExcel.open(constant_memory: true)
|
7
|
+
|
8
|
+
assert(workbook.tmp_file)
|
9
|
+
assert_match(/fast_excel.xlsx$/, workbook.filename)
|
10
|
+
|
11
|
+
result = workbook.read_string
|
12
|
+
assert(result.size > 1000)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should close workbook and delete tmp file when read_string" do
|
16
|
+
workbook = FastExcel.open
|
17
|
+
workbook.read_string
|
18
|
+
|
19
|
+
refute(File.exist?(workbook.filename))
|
20
|
+
refute(workbook.is_open)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "FastExcel::WorksheetExt append_row" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@workbook = FastExcel.open(constant_memory: false)
|
7
|
+
@worksheet = @workbook.add_worksheet
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have last_row_number = -1" do
|
11
|
+
assert_equal(-1, @worksheet.last_row_number)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should write_value and update last_row_number" do
|
15
|
+
@worksheet.write_value(0, 2, "aaa")
|
16
|
+
assert_equal(0, @worksheet.last_row_number)
|
17
|
+
assert_equal([[nil, nil, "aaa"]], get_arrays(@workbook))
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should append row and update last_row_number" do
|
21
|
+
@worksheet.append_row(["aaa", "bbb", "ccc"])
|
22
|
+
@worksheet.append_row(["ddd", "eee", "fff"])
|
23
|
+
|
24
|
+
assert_equal(1, @worksheet.last_row_number)
|
25
|
+
assert_equal([["aaa", "bbb", "ccc"], ["ddd", "eee", "fff"]], get_arrays(@workbook))
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should write_row then append and update last_row_number" do
|
29
|
+
@worksheet.write_row(3, ["aaa", "bbb", "ccc"])
|
30
|
+
@worksheet.append_row(["ddd", "eee", "fff"])
|
31
|
+
|
32
|
+
assert_equal(4, @worksheet.last_row_number)
|
33
|
+
assert_equal(
|
34
|
+
[
|
35
|
+
[nil, nil, nil],
|
36
|
+
[nil, nil, nil],
|
37
|
+
[nil, nil, nil],
|
38
|
+
["aaa", "bbb", "ccc"],
|
39
|
+
["ddd", "eee", "fff"]
|
40
|
+
],
|
41
|
+
get_arrays(@workbook)
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not reduce last_row_number" do
|
46
|
+
@worksheet.append_row(["aaa", "bbb", "ccc"])
|
47
|
+
@worksheet.append_row(["ddd", "eee", "fff"])
|
48
|
+
@worksheet.write_value(0, 4, "foo")
|
49
|
+
@worksheet.append_row(["111", "222", "333"])
|
50
|
+
|
51
|
+
assert_equal(2, @worksheet.last_row_number)
|
52
|
+
assert_equal(
|
53
|
+
[
|
54
|
+
["aaa", "bbb", "ccc", nil, "foo"],
|
55
|
+
["ddd", "eee", "fff", nil, nil],
|
56
|
+
["111", "222", "333", nil, nil]
|
57
|
+
],
|
58
|
+
get_arrays(@workbook)
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not allow to write rows that already saved" do
|
63
|
+
@workbook = FastExcel.open(constant_memory: true)
|
64
|
+
@worksheet = @workbook.add_worksheet
|
65
|
+
|
66
|
+
@worksheet.append_row(["aaa", "bbb", "ccc"])
|
67
|
+
@worksheet.append_row(["ddd", "eee", "fff"])
|
68
|
+
|
69
|
+
error = assert_raises(ArgumentError) do
|
70
|
+
@worksheet.write_value(0, 4, "foo")
|
71
|
+
end
|
72
|
+
|
73
|
+
assert_equal("Can not write to saved row in constant_memory mode (attempted row: 0, last saved row: 1)", error.message)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should write bigdecimal as a number" do
|
77
|
+
require 'bigdecimal'
|
78
|
+
|
79
|
+
@workbook = FastExcel.open(constant_memory: true)
|
80
|
+
@worksheet = @workbook.add_worksheet
|
81
|
+
|
82
|
+
@worksheet.append_row([BigDecimal.new("0.1234")])
|
83
|
+
|
84
|
+
assert_equal([[0.1234]], get_arrays(@workbook))
|
85
|
+
end
|
86
|
+
end
|
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kmadej_fast_excel_fork
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pavel Evstigneev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.9'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
33
|
+
description: Wrapper for libxlsxwriter using ffi
|
34
|
+
email:
|
35
|
+
- pavel.evst@gmail.com
|
36
|
+
executables: []
|
37
|
+
extensions:
|
38
|
+
- extconf.rb
|
39
|
+
extra_rdoc_files: []
|
40
|
+
files:
|
41
|
+
- ".gitignore"
|
42
|
+
- ".travis.yml"
|
43
|
+
- CHANGELOG.md
|
44
|
+
- Gemfile
|
45
|
+
- Gemfile.lock
|
46
|
+
- Makefile
|
47
|
+
- README.md
|
48
|
+
- Rakefile
|
49
|
+
- appveyor.yml
|
50
|
+
- benchmarks/1k_rows.rb
|
51
|
+
- benchmarks/20k_rows.rb
|
52
|
+
- benchmarks/init.rb
|
53
|
+
- benchmarks/memory.rb
|
54
|
+
- examples/example.rb
|
55
|
+
- examples/example_align.rb
|
56
|
+
- examples/example_chart.rb
|
57
|
+
- examples/example_colors.rb
|
58
|
+
- examples/example_formula.rb
|
59
|
+
- examples/example_image.rb
|
60
|
+
- examples/example_styles.rb
|
61
|
+
- examples/logo.png
|
62
|
+
- extconf.rb
|
63
|
+
- fast_excel.gemspec
|
64
|
+
- lib/fast_excel.rb
|
65
|
+
- lib/fast_excel/binding.rb
|
66
|
+
- lib/fast_excel/binding/chart.rb
|
67
|
+
- lib/fast_excel/binding/format.rb
|
68
|
+
- lib/fast_excel/binding/workbook.rb
|
69
|
+
- lib/fast_excel/binding/worksheet.rb
|
70
|
+
- libxlsxwriter/.gitignore
|
71
|
+
- libxlsxwriter/.indent.pro
|
72
|
+
- libxlsxwriter/.travis.yml
|
73
|
+
- libxlsxwriter/CONTRIBUTING.md
|
74
|
+
- libxlsxwriter/Changes.txt
|
75
|
+
- libxlsxwriter/LICENSE.txt
|
76
|
+
- libxlsxwriter/Makefile
|
77
|
+
- libxlsxwriter/Readme.md
|
78
|
+
- libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h
|
79
|
+
- libxlsxwriter/cocoapods/libxlsxwriter.modulemap
|
80
|
+
- libxlsxwriter/include/xlsxwriter.h
|
81
|
+
- libxlsxwriter/include/xlsxwriter/app.h
|
82
|
+
- libxlsxwriter/include/xlsxwriter/chart.h
|
83
|
+
- libxlsxwriter/include/xlsxwriter/common.h
|
84
|
+
- libxlsxwriter/include/xlsxwriter/content_types.h
|
85
|
+
- libxlsxwriter/include/xlsxwriter/core.h
|
86
|
+
- libxlsxwriter/include/xlsxwriter/custom.h
|
87
|
+
- libxlsxwriter/include/xlsxwriter/drawing.h
|
88
|
+
- libxlsxwriter/include/xlsxwriter/format.h
|
89
|
+
- libxlsxwriter/include/xlsxwriter/hash_table.h
|
90
|
+
- libxlsxwriter/include/xlsxwriter/packager.h
|
91
|
+
- libxlsxwriter/include/xlsxwriter/relationships.h
|
92
|
+
- libxlsxwriter/include/xlsxwriter/shared_strings.h
|
93
|
+
- libxlsxwriter/include/xlsxwriter/styles.h
|
94
|
+
- libxlsxwriter/include/xlsxwriter/theme.h
|
95
|
+
- libxlsxwriter/include/xlsxwriter/third_party/ioapi.h
|
96
|
+
- libxlsxwriter/include/xlsxwriter/third_party/queue.h
|
97
|
+
- libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h
|
98
|
+
- libxlsxwriter/include/xlsxwriter/third_party/tree.h
|
99
|
+
- libxlsxwriter/include/xlsxwriter/third_party/zip.h
|
100
|
+
- libxlsxwriter/include/xlsxwriter/utility.h
|
101
|
+
- libxlsxwriter/include/xlsxwriter/workbook.h
|
102
|
+
- libxlsxwriter/include/xlsxwriter/worksheet.h
|
103
|
+
- libxlsxwriter/include/xlsxwriter/xmlwriter.h
|
104
|
+
- libxlsxwriter/lib/.gitignore
|
105
|
+
- libxlsxwriter/libxlsxwriter.podspec
|
106
|
+
- libxlsxwriter/src/Makefile
|
107
|
+
- libxlsxwriter/src/app.c
|
108
|
+
- libxlsxwriter/src/chart.c
|
109
|
+
- libxlsxwriter/src/content_types.c
|
110
|
+
- libxlsxwriter/src/core.c
|
111
|
+
- libxlsxwriter/src/custom.c
|
112
|
+
- libxlsxwriter/src/drawing.c
|
113
|
+
- libxlsxwriter/src/format.c
|
114
|
+
- libxlsxwriter/src/hash_table.c
|
115
|
+
- libxlsxwriter/src/packager.c
|
116
|
+
- libxlsxwriter/src/relationships.c
|
117
|
+
- libxlsxwriter/src/shared_strings.c
|
118
|
+
- libxlsxwriter/src/styles.c
|
119
|
+
- libxlsxwriter/src/theme.c
|
120
|
+
- libxlsxwriter/src/utility.c
|
121
|
+
- libxlsxwriter/src/workbook.c
|
122
|
+
- libxlsxwriter/src/worksheet.c
|
123
|
+
- libxlsxwriter/src/xmlwriter.c
|
124
|
+
- libxlsxwriter/third_party/minizip/Makefile
|
125
|
+
- libxlsxwriter/third_party/minizip/Makefile.am
|
126
|
+
- libxlsxwriter/third_party/minizip/Makefile.orig
|
127
|
+
- libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt
|
128
|
+
- libxlsxwriter/third_party/minizip/MiniZip64_info.txt
|
129
|
+
- libxlsxwriter/third_party/minizip/README.txt
|
130
|
+
- libxlsxwriter/third_party/minizip/configure.ac
|
131
|
+
- libxlsxwriter/third_party/minizip/crypt.h
|
132
|
+
- libxlsxwriter/third_party/minizip/ioapi.c
|
133
|
+
- libxlsxwriter/third_party/minizip/ioapi.h
|
134
|
+
- libxlsxwriter/third_party/minizip/iowin32.c
|
135
|
+
- libxlsxwriter/third_party/minizip/iowin32.h
|
136
|
+
- libxlsxwriter/third_party/minizip/make_vms.com
|
137
|
+
- libxlsxwriter/third_party/minizip/miniunz.c
|
138
|
+
- libxlsxwriter/third_party/minizip/miniunzip.1
|
139
|
+
- libxlsxwriter/third_party/minizip/minizip.1
|
140
|
+
- libxlsxwriter/third_party/minizip/minizip.c
|
141
|
+
- libxlsxwriter/third_party/minizip/minizip.pc.in
|
142
|
+
- libxlsxwriter/third_party/minizip/mztools.c
|
143
|
+
- libxlsxwriter/third_party/minizip/mztools.h
|
144
|
+
- libxlsxwriter/third_party/minizip/unzip.c
|
145
|
+
- libxlsxwriter/third_party/minizip/unzip.h
|
146
|
+
- libxlsxwriter/third_party/minizip/zip.c
|
147
|
+
- libxlsxwriter/third_party/minizip/zip.h
|
148
|
+
- libxlsxwriter/third_party/tmpfileplus/Makefile
|
149
|
+
- libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c
|
150
|
+
- libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h
|
151
|
+
- libxlsxwriter/version.txt
|
152
|
+
- test/date_test.rb
|
153
|
+
- test/default_format_test.rb
|
154
|
+
- test/format_test.rb
|
155
|
+
- test/test_helper.rb
|
156
|
+
- test/tmpfile_test.rb
|
157
|
+
- test/worksheet_test.rb
|
158
|
+
homepage: https://github.com/paxa/fast_excel
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
metadata: {}
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - "~>"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '2.0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
requirements: []
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 2.5.1
|
179
|
+
signing_key:
|
180
|
+
specification_version: 4
|
181
|
+
summary: Ultra Fast Excel Writter
|
182
|
+
test_files: []
|