fast_excel 0.2.1 → 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.
- checksums.yaml +5 -5
- data/.dockerignore +2 -0
- data/.gitignore +7 -0
- data/.travis.yml +44 -0
- data/CHANGELOG.md +41 -1
- data/Dockerfile.test +16 -0
- data/Gemfile +5 -2
- data/Gemfile.lock +30 -23
- data/LICENSE +21 -0
- data/Makefile +13 -0
- data/README.md +177 -40
- data/Rakefile +16 -0
- data/appveyor.yml +25 -0
- data/benchmarks/1k_rows.rb +17 -4
- data/benchmarks/20k_rows.rb +4 -0
- data/benchmarks/auto_width.rb +37 -0
- data/benchmarks/init.rb +14 -2
- data/benchmarks/memory.rb +8 -0
- data/benchmarks/profiler.rb +27 -0
- data/benchmarks/write_value.rb +62 -0
- data/examples/example.rb +3 -4
- data/examples/example_align.rb +23 -0
- data/examples/example_auto_width.rb +26 -0
- data/examples/example_colors.rb +37 -0
- data/examples/example_filters.rb +36 -0
- data/examples/example_formula.rb +1 -5
- data/examples/example_hyperlink.rb +20 -0
- data/examples/example_image.rb +1 -1
- data/examples/example_styles.rb +27 -0
- data/examples/logo.png +0 -0
- data/ext/fast_excel/extconf.rb +3 -0
- data/ext/fast_excel/text_width_ext.c +460 -0
- data/fast_excel.gemspec +2 -3
- data/letters.html +114 -0
- data/lib/fast_excel.rb +455 -78
- data/lib/fast_excel/binding.rb +31 -21
- data/lib/fast_excel/binding/chart.rb +20 -1
- data/lib/fast_excel/binding/format.rb +11 -4
- data/lib/fast_excel/binding/workbook.rb +10 -2
- data/lib/fast_excel/binding/worksheet.rb +44 -27
- data/libxlsxwriter/.gitignore +1 -0
- data/libxlsxwriter/.indent.pro +8 -0
- data/libxlsxwriter/.travis.yml +12 -0
- data/libxlsxwriter/CMakeLists.txt +338 -0
- data/libxlsxwriter/CONTRIBUTING.md +1 -1
- data/libxlsxwriter/Changes.txt +162 -0
- data/libxlsxwriter/LICENSE.txt +65 -4
- data/libxlsxwriter/Makefile +33 -11
- data/libxlsxwriter/Readme.md +3 -1
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +2 -1
- data/libxlsxwriter/cocoapods/libxlsxwriter.modulemap +2 -2
- data/libxlsxwriter/include/xlsxwriter.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/app.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/chart.h +164 -13
- data/libxlsxwriter/include/xlsxwriter/chartsheet.h +544 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +35 -6
- data/libxlsxwriter/include/xlsxwriter/content_types.h +5 -2
- data/libxlsxwriter/include/xlsxwriter/core.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/custom.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/drawing.h +3 -2
- data/libxlsxwriter/include/xlsxwriter/format.h +8 -8
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/packager.h +18 -8
- data/libxlsxwriter/include/xlsxwriter/relationships.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +5 -3
- data/libxlsxwriter/include/xlsxwriter/styles.h +10 -5
- data/libxlsxwriter/include/xlsxwriter/theme.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/utility.h +35 -5
- data/libxlsxwriter/include/xlsxwriter/workbook.h +234 -57
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +780 -91
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +4 -2
- data/libxlsxwriter/libxlsxwriter.podspec +4 -2
- data/libxlsxwriter/src/Makefile +31 -6
- data/libxlsxwriter/src/app.c +2 -2
- data/libxlsxwriter/src/chart.c +116 -23
- data/libxlsxwriter/src/chartsheet.c +508 -0
- data/libxlsxwriter/src/content_types.c +12 -4
- data/libxlsxwriter/src/core.c +11 -11
- data/libxlsxwriter/src/custom.c +3 -3
- data/libxlsxwriter/src/drawing.c +114 -17
- data/libxlsxwriter/src/format.c +5 -5
- data/libxlsxwriter/src/hash_table.c +1 -1
- data/libxlsxwriter/src/packager.c +378 -61
- data/libxlsxwriter/src/relationships.c +2 -2
- data/libxlsxwriter/src/shared_strings.c +18 -4
- data/libxlsxwriter/src/styles.c +59 -12
- data/libxlsxwriter/src/theme.c +2 -2
- data/libxlsxwriter/src/utility.c +93 -6
- data/libxlsxwriter/src/workbook.c +379 -61
- data/libxlsxwriter/src/worksheet.c +1240 -174
- data/libxlsxwriter/src/xmlwriter.c +18 -9
- data/libxlsxwriter/third_party/minizip/Makefile +6 -1
- data/libxlsxwriter/third_party/minizip/ioapi.c +10 -0
- data/libxlsxwriter/third_party/minizip/zip.c +2 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +2 -2
- data/libxlsxwriter/version.txt +1 -1
- data/test/auto_width_test.rb +19 -0
- data/test/date_test.rb +34 -0
- data/test/format_test.rb +179 -0
- data/test/reopen_test.rb +22 -0
- data/test/test_helper.rb +23 -4
- data/test/text_width_test.rb +80 -0
- data/test/tmpfile_test.rb +1 -0
- data/test/validations_test.rb +47 -0
- data/test/worksheet_test.rb +129 -0
- metadata +34 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: af06f03372f15efb18eaf09669f7822ee81b67a5d4c6be7a55c3b8eb2609fd82
|
|
4
|
+
data.tar.gz: af892b143b010078e56380d38c76216ff19cb524f3e73c5206d18131546f216c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 979827252546904e71283dcf5996636fad7d04963ea1d07f6adf916484ac94a39e9b5a6f7d479529cb42971f53dc2dbadf0c08d1d57caf3eac7a91747308b6f2
|
|
7
|
+
data.tar.gz: 6a64e0cfa1894134759a2a1784c78c2641ff6aec2b81c48e9afb81fcc335d24ff7a0022f3ef252bb2ba0824fc8afe5220159829bee5bc32556687ed170009bbd
|
data/.dockerignore
ADDED
data/.gitignore
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.ruby-version
|
|
2
|
+
.idea/
|
|
2
3
|
try.c
|
|
3
4
|
try.rb
|
|
4
5
|
gen.rb
|
|
@@ -7,7 +8,13 @@ gen_ffi.rb
|
|
|
7
8
|
a.out
|
|
8
9
|
.DS_Store
|
|
9
10
|
*.gem
|
|
11
|
+
*.cmake
|
|
12
|
+
libxlsxwriter/CmakeFiles
|
|
13
|
+
libxlsxwriter/CmakeCache.txt
|
|
10
14
|
libxlsxwriter/dev
|
|
11
15
|
libxlsxwriter/docs
|
|
12
16
|
libxlsxwriter/examples
|
|
13
17
|
libxlsxwriter/test
|
|
18
|
+
ext/fast_excel/text_width_ext.o
|
|
19
|
+
ext/fast_excel/Makefile
|
|
20
|
+
ext/fast_excel/text_width_ext.bundle
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: ruby
|
|
3
|
+
|
|
4
|
+
matrix:
|
|
5
|
+
include:
|
|
6
|
+
# - os: linux
|
|
7
|
+
# rvm: 2.2.10
|
|
8
|
+
# - os: osx
|
|
9
|
+
# rvm: 2.2.10
|
|
10
|
+
- os: linux
|
|
11
|
+
rvm: 2.3.8
|
|
12
|
+
- os: osx
|
|
13
|
+
rvm: 2.3.8
|
|
14
|
+
- os: linux
|
|
15
|
+
rvm: 2.4.6
|
|
16
|
+
- os: osx
|
|
17
|
+
rvm: 2.4.6
|
|
18
|
+
- os: linux
|
|
19
|
+
rvm: 2.5.5
|
|
20
|
+
- os: osx
|
|
21
|
+
rvm: 2.5.5
|
|
22
|
+
- os: linux
|
|
23
|
+
rvm: 2.6.3
|
|
24
|
+
env: BUILD_DOCKER=true
|
|
25
|
+
services:
|
|
26
|
+
- docker
|
|
27
|
+
- os: osx
|
|
28
|
+
rvm: 2.6.3
|
|
29
|
+
osx_image: xcode10.2
|
|
30
|
+
before_script:
|
|
31
|
+
- ls -lah /Applications
|
|
32
|
+
- sudo xcode-select -s /Applications/Xcode-10.2.1.app/Contents/Developer
|
|
33
|
+
- clang --version
|
|
34
|
+
fast_finish: true
|
|
35
|
+
|
|
36
|
+
before_install:
|
|
37
|
+
- gem install bundler -v 2.0.2
|
|
38
|
+
|
|
39
|
+
script:
|
|
40
|
+
- bundle install
|
|
41
|
+
- make
|
|
42
|
+
- bundle exec rake test
|
|
43
|
+
- bundle exec rake examples
|
|
44
|
+
- if [ -n "$BUILD_DOCKER" ]; then docker build . -f Dockerfile.test --build-arg TRAVIS_COMMIT --build-arg TRAVIS_BRANCH ; fi
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
#### Version 0.3.0 - 23 jul 2020
|
|
2
|
+
|
|
3
|
+
* Add support for FastExcel::URL
|
|
4
|
+
* Add support for writing boolean values
|
|
5
|
+
* Add enable_filters!(end_col: X)
|
|
6
|
+
* Allow to open with an empty existing file
|
|
7
|
+
* Add missing enums to chart
|
|
8
|
+
* Don't change sheet name from "" to nil
|
|
9
|
+
* Support build with docker
|
|
10
|
+
* Fix crash when sheet name exceeds maximum length.
|
|
11
|
+
* [BREAKING CHANGE] Rename `worksheet.right_to_left` to `worksheet.set_right_to_left`:
|
|
12
|
+
- now it will work properly when using the `pry-rails` gem, not forcing the document start from right even when this method is not called.
|
|
13
|
+
|
|
14
|
+
#### Version 0.2.6 - 26 jan 2019
|
|
15
|
+
|
|
16
|
+
* Add column auto width (thanks to @duffyjp)
|
|
17
|
+
|
|
18
|
+
#### Version 0.2.5 - 22 jun 2018
|
|
19
|
+
|
|
20
|
+
* Update libxlsxwriter to 0.7.7
|
|
21
|
+
|
|
22
|
+
#### Version 0.2.4 - 13 mar 2018
|
|
23
|
+
|
|
24
|
+
* Update libxlsxwriter to 0.7.6
|
|
25
|
+
* Don’t crash process when duplicated worksheet name
|
|
26
|
+
|
|
27
|
+
#### Version 0.2.3 - 27 oct 2017
|
|
28
|
+
|
|
29
|
+
* Allow Date along with DateTime in write_value (thanks to @noxern)
|
|
30
|
+
|
|
31
|
+
#### Version 0.2.2 - 20 sep 2017
|
|
32
|
+
|
|
33
|
+
* Nice setters and getters for format.align
|
|
34
|
+
* Add nice setters for colors and borders
|
|
35
|
+
* Add sheet.append_row, sheet.last_row_number
|
|
36
|
+
* Run tests in CI
|
|
37
|
+
* Performance optimizations and type check refactoring
|
|
38
|
+
* Add styles_example.rb
|
|
39
|
+
* Fix assigning align from other format
|
|
40
|
+
|
|
1
41
|
#### Version 0.2.1 - 20 jun 2017
|
|
2
42
|
|
|
3
43
|
* Add FastExcel::Formula
|
|
@@ -10,4 +50,4 @@
|
|
|
10
50
|
|
|
11
51
|
#### Version 0.1.0 - 24 feb 2017
|
|
12
52
|
|
|
13
|
-
Initial
|
|
53
|
+
Initial
|
data/Dockerfile.test
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
FROM ruby
|
|
2
|
+
|
|
3
|
+
RUN gem install fast_excel
|
|
4
|
+
|
|
5
|
+
ARG TRAVIS_COMMIT
|
|
6
|
+
ARG TRAVIS_BRANCH
|
|
7
|
+
|
|
8
|
+
RUN echo "source 'https://rubygems.org'" > Gemfile
|
|
9
|
+
|
|
10
|
+
RUN [ -z "$TRAVIS_COMMIT" ] && \
|
|
11
|
+
echo "gem 'fast_excel', git: 'https://github.com/Paxa/fast_excel.git'" >> Gemfile || true
|
|
12
|
+
RUN [ -z "$TRAVIS_COMMIT" ] || \
|
|
13
|
+
echo "gem 'fast_excel', git: 'https://github.com/Paxa/fast_excel.git', branch: '$TRAVIS_BRANCH', ref: '$TRAVIS_COMMIT'" >> Gemfile
|
|
14
|
+
|
|
15
|
+
RUN cat Gemfile
|
|
16
|
+
RUN bundle
|
data/Gemfile
CHANGED
|
@@ -3,7 +3,9 @@ source 'https://rubygems.org'
|
|
|
3
3
|
gem 'ffi'
|
|
4
4
|
gem 'ffi_gen', require: false
|
|
5
5
|
|
|
6
|
-
gem '
|
|
6
|
+
gem 'rake'
|
|
7
|
+
|
|
8
|
+
gem 'roo', '2.8.3', git: 'https://github.com/roo-rb/roo.git', tag: 'v2.8.3'
|
|
7
9
|
|
|
8
10
|
gem 'minitest'
|
|
9
11
|
gem 'minitest-reporters'
|
|
@@ -11,5 +13,6 @@ gem 'minitest-reporters'
|
|
|
11
13
|
# For benchmakrs
|
|
12
14
|
gem 'axlsx', git: 'https://github.com/randym/axlsx.git'
|
|
13
15
|
gem 'write_xlsx'
|
|
16
|
+
gem 'xlsxtream'
|
|
14
17
|
gem 'benchmark-ips'
|
|
15
|
-
gem 'process_memory', git: 'https://github.com/paxa/process_memory'
|
|
18
|
+
gem 'process_memory', git: 'https://github.com/paxa/process_memory', platforms: :ruby
|
data/Gemfile.lock
CHANGED
|
@@ -1,54 +1,59 @@
|
|
|
1
1
|
GIT
|
|
2
2
|
remote: https://github.com/paxa/process_memory
|
|
3
|
-
revision:
|
|
3
|
+
revision: 282c75336a4a6b92207cd1eaa57f20887b92601e
|
|
4
4
|
specs:
|
|
5
5
|
process_memory (0.1)
|
|
6
6
|
|
|
7
7
|
GIT
|
|
8
8
|
remote: https://github.com/randym/axlsx.git
|
|
9
|
-
revision:
|
|
9
|
+
revision: 8e7b4b3b7259103452c191f73ce0bf64f66033fe
|
|
10
10
|
specs:
|
|
11
|
-
axlsx (
|
|
12
|
-
htmlentities (~> 4.3.4)
|
|
11
|
+
axlsx (3.0.0.pre)
|
|
12
|
+
htmlentities (~> 4.3, >= 4.3.4)
|
|
13
13
|
mimemagic (~> 0.3)
|
|
14
|
-
nokogiri (>= 1.
|
|
15
|
-
rubyzip (>= 1.2.1)
|
|
14
|
+
nokogiri (~> 1.8, >= 1.8.2)
|
|
15
|
+
rubyzip (~> 1.2, >= 1.2.1)
|
|
16
16
|
|
|
17
17
|
GIT
|
|
18
18
|
remote: https://github.com/roo-rb/roo.git
|
|
19
|
-
revision:
|
|
19
|
+
revision: d416f1520c50bbab160ca2ed9a49498fcc3edf50
|
|
20
|
+
tag: v2.8.3
|
|
20
21
|
specs:
|
|
21
|
-
roo (2.
|
|
22
|
+
roo (2.8.3)
|
|
22
23
|
nokogiri (~> 1)
|
|
23
|
-
rubyzip (>= 1.
|
|
24
|
+
rubyzip (>= 1.3.0, < 3.0.0)
|
|
24
25
|
|
|
25
26
|
GEM
|
|
26
27
|
remote: https://rubygems.org/
|
|
27
28
|
specs:
|
|
28
29
|
ansi (1.5.0)
|
|
29
|
-
benchmark-ips (2.
|
|
30
|
-
builder (3.2.
|
|
31
|
-
ffi (1.
|
|
30
|
+
benchmark-ips (2.8.2)
|
|
31
|
+
builder (3.2.4)
|
|
32
|
+
ffi (1.13.1)
|
|
32
33
|
ffi_gen (1.2.0)
|
|
33
34
|
ffi (~> 1.0)
|
|
34
35
|
htmlentities (4.3.4)
|
|
35
|
-
mimemagic (0.3.
|
|
36
|
-
mini_portile2 (2.
|
|
37
|
-
minitest (5.
|
|
38
|
-
minitest-reporters (1.
|
|
36
|
+
mimemagic (0.3.5)
|
|
37
|
+
mini_portile2 (2.4.0)
|
|
38
|
+
minitest (5.14.1)
|
|
39
|
+
minitest-reporters (1.4.2)
|
|
39
40
|
ansi
|
|
40
41
|
builder
|
|
41
42
|
minitest (>= 5.0)
|
|
42
43
|
ruby-progressbar
|
|
43
|
-
nokogiri (1.
|
|
44
|
-
mini_portile2 (~> 2.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
nokogiri (1.10.10)
|
|
45
|
+
mini_portile2 (~> 2.4.0)
|
|
46
|
+
rake (13.0.1)
|
|
47
|
+
ruby-progressbar (1.10.1)
|
|
48
|
+
rubyzip (1.3.0)
|
|
49
|
+
write_xlsx (0.85.7)
|
|
48
50
|
rubyzip (>= 1.0.0)
|
|
49
51
|
zip-zip
|
|
52
|
+
xlsxtream (2.4.0)
|
|
53
|
+
zip_tricks (>= 4.5, < 6)
|
|
50
54
|
zip-zip (0.3)
|
|
51
55
|
rubyzip (>= 1.0.0)
|
|
56
|
+
zip_tricks (5.3.1)
|
|
52
57
|
|
|
53
58
|
PLATFORMS
|
|
54
59
|
ruby
|
|
@@ -61,8 +66,10 @@ DEPENDENCIES
|
|
|
61
66
|
minitest
|
|
62
67
|
minitest-reporters
|
|
63
68
|
process_memory!
|
|
64
|
-
|
|
69
|
+
rake
|
|
70
|
+
roo (= 2.8.3)!
|
|
65
71
|
write_xlsx
|
|
72
|
+
xlsxtream
|
|
66
73
|
|
|
67
74
|
BUNDLED WITH
|
|
68
|
-
|
|
75
|
+
2.0.2
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Pavel Evstigneev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/Makefile
CHANGED
|
@@ -3,9 +3,22 @@ ifdef V
|
|
|
3
3
|
Q=
|
|
4
4
|
endif
|
|
5
5
|
|
|
6
|
+
# with xcode better to use cmake
|
|
7
|
+
UNAME_S := $(shell uname -s)
|
|
8
|
+
ifeq ($(UNAME_S),"Darwin")
|
|
9
|
+
USE_CMAKE := $(shell command -v cmake 2> /dev/null)
|
|
10
|
+
endif
|
|
11
|
+
|
|
6
12
|
all :
|
|
13
|
+
# @echo "Compiling ext/text_width ..."
|
|
14
|
+
# rake compile
|
|
7
15
|
@echo "Compiling libxlsxwriter ..."
|
|
16
|
+
ifdef USE_CMAKE
|
|
17
|
+
@echo "run cmake libxlsxwriter ..."
|
|
18
|
+
cmake libxlsxwriter
|
|
19
|
+
else
|
|
8
20
|
$(Q)$(MAKE) -C libxlsxwriter
|
|
21
|
+
endif
|
|
9
22
|
|
|
10
23
|
clean :
|
|
11
24
|
$(Q)$(MAKE) clean -C libxlsxwriter
|
data/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# Ultra Fast Excel
|
|
1
|
+
# Ultra Fast Excel Writer for Ruby
|
|
2
2
|
|
|
3
3
|
```ruby
|
|
4
4
|
require 'fast_excel'
|
|
5
5
|
|
|
6
|
-
workbook = FastExcel.open("
|
|
6
|
+
workbook = FastExcel.open("hello_world.xlsx", constant_memory: true)
|
|
7
7
|
workbook.default_format.set(
|
|
8
8
|
font_size: 0, # user's default
|
|
9
9
|
font_family: "Arial"
|
|
@@ -11,7 +11,7 @@ workbook.default_format.set(
|
|
|
11
11
|
|
|
12
12
|
worksheet = workbook.add_worksheet("Example Report")
|
|
13
13
|
|
|
14
|
-
bold = workbook.
|
|
14
|
+
bold = workbook.bold_format
|
|
15
15
|
worksheet.set_column(0, 0, FastExcel::DEF_COL_WIDTH, bold)
|
|
16
16
|
|
|
17
17
|
price = workbook.number_format("#,##0.00")
|
|
@@ -20,56 +20,179 @@ worksheet.set_column(1, 1, 20, price)
|
|
|
20
20
|
date_format = workbook.number_format("[$-409]m/d/yy h:mm AM/PM;@")
|
|
21
21
|
worksheet.set_column(2, 2, 20, date_format)
|
|
22
22
|
|
|
23
|
-
worksheet.
|
|
23
|
+
worksheet.append_row(["message", "price", "date"], bold)
|
|
24
24
|
|
|
25
25
|
for i in 1..1000
|
|
26
|
-
worksheet.
|
|
26
|
+
worksheet.append_row(["Hello", (rand * 10_000_000).round(2), Time.now])
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
worksheet.
|
|
29
|
+
worksheet.append_row(["Sum", FastExcel::Formula.new("SUM(B2:B1001)")], bold)
|
|
30
30
|
|
|
31
31
|
workbook.close
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
See [more examples](https://github.com/Paxa/fast_excel/tree/master/examples)
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
This repository and gem contain sources of [libxlsxwriter](https://github.com/jmcnamara/libxlsxwriter)
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
# Gemfile
|
|
42
|
+
gem 'fast_excel'
|
|
39
43
|
```
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
write_xlsx: 6.9 i/s - 4.62x slower
|
|
44
|
+
Or
|
|
45
|
+
```
|
|
46
|
+
gem install fast_excel
|
|
44
47
|
```
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Create Document
|
|
52
|
+
```ruby
|
|
53
|
+
workbook = FastExcel.open # creates tmp file
|
|
54
|
+
# ...
|
|
55
|
+
send_data(workbook.read_string, filename: "table.xlsx") # read tmp file and delete it
|
|
47
56
|
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
|
|
58
|
+
Also can use `workbook.remove_tmp_file` to delete tmp file manually
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
**Constant memory mode**: saves each row to disk, good for really big files but can not change previous lines that already saved
|
|
62
|
+
```ruby
|
|
63
|
+
workbook = FastExcel.open(constant_memory: true)
|
|
52
64
|
```
|
|
53
65
|
|
|
54
|
-
|
|
66
|
+
**Save to file**
|
|
67
|
+
```ruby
|
|
68
|
+
workbook = FastExcel.open("my_dinner.xlsx")
|
|
55
69
|
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
|
|
71
|
+
### Write Data
|
|
72
|
+
FastExcel will automatically detect data type and one of `write_number` or `write_datetime` or `write_formula` or `write_string` or `write_url`
|
|
73
|
+
```ruby
|
|
74
|
+
workbook = FastExcel.open
|
|
75
|
+
worksheet = workbook.add_worksheet
|
|
76
|
+
|
|
77
|
+
# write specific type value value
|
|
78
|
+
worksheet.write_number(row = 0, col = 5, 1_234_567, format = nil)
|
|
79
|
+
|
|
80
|
+
# write value with type detection
|
|
81
|
+
worksheet.write_value(row = 0, col = 5, 1_234_567, format = nil)
|
|
82
|
+
|
|
83
|
+
# write row of values. format argument can be format object or array of format objects
|
|
84
|
+
worksheet.write_row(row = 1, ["strong", 123_456, Time.now], format = nil)
|
|
85
|
+
|
|
86
|
+
# write row to the bottom
|
|
87
|
+
worksheet.append_row(["strong", 123_456, Time.now], )
|
|
88
|
+
|
|
89
|
+
# shortcut for append_row()
|
|
90
|
+
worksheet << ["strong", 123_456, Time.now]
|
|
59
91
|
```
|
|
60
92
|
|
|
61
|
-
|
|
93
|
+
**Saving dates**: excel store dates as number of days since 1st January 1900, and FastExcel will make it for you.
|
|
62
94
|
|
|
95
|
+
To make saving of dates slightly faster can use `FastExcel.date_num` helper:
|
|
63
96
|
```ruby
|
|
64
|
-
|
|
65
|
-
|
|
97
|
+
date_format = workbook.number_format("[$-409]m/d/yy hh:mm;@")
|
|
98
|
+
worksheet.write_number(0, 0, FastExcel.date_num(Time.now, Time.zone.utc_offset), date_format)
|
|
66
99
|
```
|
|
67
|
-
|
|
100
|
+
|
|
101
|
+
**Formulas**: special type of value in excel
|
|
102
|
+
```ruby
|
|
103
|
+
worksheet << [1, 2, 3, 4]
|
|
104
|
+
worksheet << [FastExcel::Formula.new("SUM(A1:D1)")] # A2 will be shown as 10
|
|
68
105
|
```
|
|
69
|
-
|
|
106
|
+
|
|
107
|
+
**URL**: Link to website or something else
|
|
108
|
+
```ruby
|
|
109
|
+
url_format = workbook.add_format(underline: :underline_single, font_color: :blue) # format is optional
|
|
110
|
+
worksheet.append_row([
|
|
111
|
+
FastExcel::URL.new("https://github.com/Paxa/fast_excel"),
|
|
112
|
+
FastExcel::URL.new("postgres://localhost")
|
|
113
|
+
], url_format)
|
|
114
|
+
# or
|
|
115
|
+
worksheet.write_url(0, 2, "https://github.com/Paxa/fast_excel", url_format)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
### Data Formatting
|
|
120
|
+
```ruby
|
|
121
|
+
format = worksheet.add_format(
|
|
122
|
+
bold: true,
|
|
123
|
+
italic: true,
|
|
124
|
+
font_outline: true,
|
|
125
|
+
font_shadow: true,
|
|
126
|
+
text_wrap: true,
|
|
127
|
+
font_strikeout: true,
|
|
128
|
+
shrink: true,
|
|
129
|
+
text_justlast: true,
|
|
130
|
+
font_size: 13, # default is 11, use 0 for user's default
|
|
131
|
+
font_name: "Arial", # default is Calibri, also accessible via font_family
|
|
132
|
+
font_color: :orange, # can use RGB hex as "#FF0000" or 0x00FF00 or color name as symbol or string
|
|
133
|
+
font_script: :font_subscript,
|
|
134
|
+
rotation: 10,
|
|
135
|
+
underline: :underline_single, # or :underline_double or :underline_single_accounting or :underline_double_accounting
|
|
136
|
+
indent: 1,
|
|
137
|
+
# border styles
|
|
138
|
+
border: :border_thin,
|
|
139
|
+
left: :medium,
|
|
140
|
+
top: :dashed,
|
|
141
|
+
right: :double,
|
|
142
|
+
bottom: :hair,
|
|
143
|
+
bottom_color: :alice_blue,
|
|
144
|
+
top_color: "#11ABCD",
|
|
145
|
+
# Align
|
|
146
|
+
align: {h: :align_center, v: :align_vertical_center},
|
|
147
|
+
num_format: "#,##0.00"
|
|
148
|
+
)
|
|
70
149
|
```
|
|
71
150
|
|
|
72
|
-
|
|
151
|
+
**Shortcuts**:
|
|
152
|
+
```ruby
|
|
153
|
+
workbook.bold_format # bold text
|
|
154
|
+
workbook.number_format("[$-409]m/d/yy h:mm AM/PM;@") # format for date
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Set Column Width
|
|
158
|
+
|
|
159
|
+
```ruby
|
|
160
|
+
worksheet.set_column(start_col, end_col, width = nil, format = nil)
|
|
161
|
+
# or
|
|
162
|
+
worksheet.set_column_width(col, width = 60)
|
|
163
|
+
# or
|
|
164
|
+
worksheet.set_columns_width(start_col, end_col, width = 60)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Set Row Height
|
|
168
|
+
```ruby
|
|
169
|
+
worksheet.set_row(row_num = 0, height = 30, format = nil)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Column Auto Width
|
|
173
|
+
|
|
174
|
+
Column authwidth only works for string values, because numbers may have custom formatting
|
|
175
|
+
|
|
176
|
+
Enabling column auto widths will slow down writing string values for about 15-25%
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
require 'fast_excel'
|
|
180
|
+
|
|
181
|
+
workbook = FastExcel.open(constant_memory: true)
|
|
182
|
+
|
|
183
|
+
worksheet = workbook.add_worksheet
|
|
184
|
+
worksheet.auto_width = true
|
|
185
|
+
|
|
186
|
+
worksheet.append_row(["some text", "some longer text for example"])
|
|
187
|
+
|
|
188
|
+
content = workbook.read_string
|
|
189
|
+
File.open('./some_file.xlsx', 'wb') {|f| f.write(content) }
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+

|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
### API
|
|
73
196
|
|
|
74
197
|
This gem is FFI binding for libxlsxwriter C library with some syntax sugar. All original functions is avaliable, for example:
|
|
75
198
|
|
|
@@ -81,15 +204,29 @@ worksheet.activate
|
|
|
81
204
|
|
|
82
205
|
Full libxlsxwriter documentation: [http://libxlsxwriter.github.io/](http://libxlsxwriter.github.io/)
|
|
83
206
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
207
|
+
Generated rdoc: [rubydoc.info/github/Paxa/fast_excel](https://www.rubydoc.info/github/Paxa/fast_excel)
|
|
208
|
+
|
|
209
|
+
## Benchmarks
|
|
210
|
+
|
|
211
|
+
1000 rows:
|
|
212
|
+
```
|
|
213
|
+
Comparison:
|
|
214
|
+
FastExcel: 31.7 i/s
|
|
215
|
+
Axlsx: 8.0 i/s - 3.98x slower
|
|
216
|
+
write_xlsx: 6.9 i/s - 4.62x slower
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
20000 rows:
|
|
220
|
+
```
|
|
221
|
+
Comparison:
|
|
222
|
+
FastExcel: 1.4 i/s
|
|
223
|
+
Axlsx: 0.4 i/s - 3.46x slower
|
|
224
|
+
write_xlsx: 0.1 i/s - 17.04x slower
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Max memory usage, generating 100k rows:
|
|
228
|
+
```
|
|
229
|
+
FastExcel - 20 MB
|
|
230
|
+
Axlsx - 60 MB
|
|
231
|
+
write_xlsx - 100 MB
|
|
232
|
+
```
|