spreadsheet_architect 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -3
- data/README.md +22 -17
- data/lib/spreadsheet_architect/class_methods/xlsx.rb +0 -2
- data/lib/spreadsheet_architect/utils/xlsx.rb +3 -3
- data/lib/spreadsheet_architect/version.rb +1 -1
- metadata +5 -540
- data/lib/spreadsheet_architect/axlsx_string_width_patch.rb +0 -23
- data/test/dummy_app/Rakefile +0 -7
- data/test/dummy_app/app/assets/config/manifest.js +0 -3
- data/test/dummy_app/app/assets/javascripts/application.js +0 -0
- data/test/dummy_app/app/assets/stylesheets/application.css +0 -3
- data/test/dummy_app/app/controllers/application_controller.rb +0 -3
- data/test/dummy_app/app/controllers/spreadsheets_controller.rb +0 -77
- data/test/dummy_app/app/models/active_model_object.rb +0 -15
- data/test/dummy_app/app/models/application_record.rb +0 -3
- data/test/dummy_app/app/models/custom_columns_method_post.rb +0 -29
- data/test/dummy_app/app/models/custom_post.rb +0 -28
- data/test/dummy_app/app/models/legacy_plain_ruby_object.rb +0 -14
- data/test/dummy_app/app/models/plain_ruby_object.rb +0 -12
- data/test/dummy_app/app/models/post.rb +0 -6
- data/test/dummy_app/app/views/layouts/application.html.erb +0 -14
- data/test/dummy_app/config/application.rb +0 -58
- data/test/dummy_app/config/boot.rb +0 -10
- data/test/dummy_app/config/database.yml +0 -25
- data/test/dummy_app/config/environment.rb +0 -5
- data/test/dummy_app/config/environments/test.rb +0 -41
- data/test/dummy_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy_app/config/initializers/inflections.rb +0 -10
- data/test/dummy_app/config/initializers/mime_types.rb +0 -5
- data/test/dummy_app/config/initializers/secret_token.rb +0 -11
- data/test/dummy_app/config/initializers/session_store.rb +0 -8
- data/test/dummy_app/config/initializers/spreadsheet_architect.rb +0 -11
- data/test/dummy_app/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy_app/config/locales/en.yml +0 -5
- data/test/dummy_app/config/routes.rb +0 -6
- data/test/dummy_app/config/secrets.yml +0 -22
- data/test/dummy_app/config.ru +0 -4
- data/test/dummy_app/db/migrate/20170103234524_add_posts.rb +0 -10
- data/test/dummy_app/db/schema.rb +0 -23
- data/test/dummy_app/db/test.sqlite3 +0 -0
- data/test/dummy_app/log/test.log +0 -113964
- data/test/dummy_app/tmp/2.0.1/integration/alt_xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/integration/csv.csv +0 -6
- data/test/dummy_app/tmp/2.0.1/integration/ods.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/integration/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/kitchen_sink.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/kitchen_sink.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.csv +0 -3
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/empty.csv +0 -1
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.csv +0 -6
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/ActiveModelObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/data.csv +0 -3
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/empty.csv +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/instances.csv +0 -6
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomColumnsMethodPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.csv +0 -3
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.csv +0 -1
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.csv +0 -6
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/CustomPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.csv +0 -3
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.csv +0 -1
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.csv +0 -6
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/LegacyPlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.csv +0 -3
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.csv +0 -1
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.csv +0 -6
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/PlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/data.csv +0 -3
- data/test/dummy_app/tmp/2.0.1/models/Post/data.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/data.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/empty.csv +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/empty.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/empty.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/instances.csv +0 -6
- data/test/dummy_app/tmp/2.0.1/models/Post/instances.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/models/Post/instances.xlsx +0 -0
- data/test/dummy_app/tmp/2.0.1/multi_sheet.ods +0 -0
- data/test/dummy_app/tmp/2.0.1/multi_sheet.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/integration/alt_xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/integration/csv.csv +0 -6
- data/test/dummy_app/tmp/3.0.0.pre/integration/ods.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/integration/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/kitchen_sink.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/kitchen_sink.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.csv +0 -3
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.csv +0 -1
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.csv +0 -6
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/ActiveModelObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/data.csv +0 -3
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/empty.csv +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/instances.csv +0 -6
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomColumnsMethodPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.csv +0 -3
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.csv +0 -1
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.csv +0 -6
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/CustomPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.csv +0 -3
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.csv +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.csv +0 -6
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/LegacyPlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.csv +0 -3
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.csv +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.csv +0 -6
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/PlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.csv +0 -3
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/data.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.csv +0 -1
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/empty.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/instances.csv +0 -6
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/instances.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/models/Post/instances.xlsx +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/multi_sheet.ods +0 -0
- data/test/dummy_app/tmp/3.0.0.pre/multi_sheet.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/integration/alt_xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/integration/csv.csv +0 -6
- data/test/dummy_app/tmp/axlsx-master/integration/ods.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/integration/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/kitchen_sink.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/kitchen_sink.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.csv +0 -4
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.csv +0 -1
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.csv +0 -6
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/ActiveModelObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/data.csv +0 -4
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/empty.csv +0 -1
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/instances.csv +0 -6
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomColumnsMethodPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.csv +0 -4
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.csv +0 -1
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.csv +0 -6
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/CustomPost/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.csv +0 -4
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.csv +0 -1
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.csv +0 -6
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/LegacyPlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.csv +0 -4
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.csv +0 -1
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.csv +0 -6
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/PlainRubyObject/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/data.csv +0 -4
- data/test/dummy_app/tmp/axlsx-master/models/Post/data.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/data.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/empty.csv +0 -1
- data/test/dummy_app/tmp/axlsx-master/models/Post/empty.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/empty.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/instances.csv +0 -6
- data/test/dummy_app/tmp/axlsx-master/models/Post/instances.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/models/Post/instances.xlsx +0 -0
- data/test/dummy_app/tmp/axlsx-master/multi_sheet.ods +0 -0
- data/test/dummy_app/tmp/axlsx-master/multi_sheet.xlsx +0 -0
- data/test/integration/application_test.rb +0 -38
- data/test/models/all_models_test.rb +0 -108
- data/test/test_helper.rb +0 -87
- data/test/unit/ods/general_test.rb +0 -121
- data/test/unit/rails/formats_test.rb +0 -15
- data/test/unit/spreadsheet_architect/exceptions_test.rb +0 -195
- data/test/unit/spreadsheet_architect/spreadsheet_architect_test.rb +0 -15
- data/test/unit/spreadsheet_architect/utils/ods_test.rb +0 -58
- data/test/unit/spreadsheet_architect/utils/xlsx_test.rb +0 -114
- data/test/unit/spreadsheet_architect/utils_test.rb +0 -197
- data/test/unit/xlsx/freeze_test.rb +0 -79
- data/test/unit/xlsx/general_test.rb +0 -199
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SpreadsheetArchitect::Utils::OdsTest < ActiveSupport::TestCase
|
4
|
-
klass = SpreadsheetArchitect::Utils::ODS
|
5
|
-
|
6
|
-
describe "get_cell_type" do
|
7
|
-
describe "without passing the type argument" do
|
8
|
-
test "it gets the correct cell type" do
|
9
|
-
assert_equal :string, klass.get_cell_type("foobar")
|
10
|
-
assert_equal :float, klass.get_cell_type(1)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "when passing the type argument" do
|
15
|
-
test "returns the given type" do
|
16
|
-
assert_equal "foobar", klass.get_cell_type(1, "foobar")
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "hyperlinks" do
|
20
|
-
test "returns :string" do
|
21
|
-
assert_equal :string, klass.get_cell_type("foobar", :hyperlink)
|
22
|
-
assert_equal :string, klass.get_cell_type(1, :hyperlink)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "convert_styles" do
|
29
|
-
test "convert_styles_to_ods" do
|
30
|
-
ods_styles = klass.convert_styles({
|
31
|
-
background_color: '333333',
|
32
|
-
color: '000000',
|
33
|
-
align: true,
|
34
|
-
bold: true,
|
35
|
-
font_size: 14,
|
36
|
-
italic: true,
|
37
|
-
underline: true,
|
38
|
-
test: true
|
39
|
-
})
|
40
|
-
|
41
|
-
assert_equal(ods_styles, {
|
42
|
-
'cell' => {
|
43
|
-
'background-color' => '#333333'
|
44
|
-
},
|
45
|
-
'text' => {
|
46
|
-
'color' => '#000000',
|
47
|
-
'align' => true,
|
48
|
-
'font-weight' => 'bold',
|
49
|
-
'font-size' => 14,
|
50
|
-
'font-style' => 'italic',
|
51
|
-
'text-underline-type' => 'single',
|
52
|
-
'text-underline-style' => 'solid'
|
53
|
-
}
|
54
|
-
})
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SpreadsheetArchitectXlsxUtilsTest < ActiveSupport::TestCase
|
4
|
-
klass = SpreadsheetArchitect::Utils::XLSX
|
5
|
-
|
6
|
-
def setup
|
7
|
-
end
|
8
|
-
|
9
|
-
def teardown
|
10
|
-
end
|
11
|
-
|
12
|
-
test "convert_styles_to_axlsx" do
|
13
|
-
xlsx_styles = klass.convert_styles_to_axlsx({background_color: '333333', color: '000000', align: true, bold: true, font_size: 14, italic: true, underline: true, test: true})
|
14
|
-
|
15
|
-
assert_equal(xlsx_styles, {bg_color: '333333', fg_color: '000000', alignment: {horizontal: true}, b: true, sz: 14, i: true, u: true, test: true})
|
16
|
-
end
|
17
|
-
|
18
|
-
test "get_type" do
|
19
|
-
assert_equal(klass.get_type('string'), :string)
|
20
|
-
assert_equal(klass.get_type(123.01), :float)
|
21
|
-
assert_equal(klass.get_type(BigDecimal('123.01')), :float)
|
22
|
-
assert_equal(klass.get_type(10), :integer)
|
23
|
-
assert_equal(klass.get_type(:test), :string)
|
24
|
-
assert_equal(klass.get_type(Time.now.to_date), :date)
|
25
|
-
assert_equal(klass.get_type(DateTime.now), :time)
|
26
|
-
assert_equal(klass.get_type(Time.now), :time)
|
27
|
-
end
|
28
|
-
|
29
|
-
test "range_hash_to_str" do
|
30
|
-
num_columns = 26
|
31
|
-
num_rows = 10
|
32
|
-
|
33
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeError do
|
34
|
-
klass.range_hash_to_str({}, num_columns, num_rows)
|
35
|
-
end
|
36
|
-
|
37
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeOptionError do
|
38
|
-
klass.range_hash_to_str({columns: [1,2,3], rows: 1}, num_columns, num_rows)
|
39
|
-
end
|
40
|
-
|
41
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeOptionError do
|
42
|
-
klass.range_hash_to_str({columns: 1, rows: [1,2,3]}, num_columns, num_rows)
|
43
|
-
end
|
44
|
-
|
45
|
-
assert_equal klass.range_hash_to_str({columns: 1}, num_columns, num_rows), "B1:B10"
|
46
|
-
|
47
|
-
assert_equal klass.range_hash_to_str({rows: 1}, num_columns, num_rows), "A1:Z1"
|
48
|
-
|
49
|
-
assert_equal klass.range_hash_to_str({columns: 0, rows: 1}, num_columns, num_rows), "A1:A1"
|
50
|
-
|
51
|
-
assert_equal klass.range_hash_to_str({columns: (0..2), rows: (1..3)}, num_columns, num_rows), "A1:C3"
|
52
|
-
|
53
|
-
assert_equal klass.range_hash_to_str({columns: ('A'..'C'), rows: (1..3)}, num_columns, num_rows), "A1:C3"
|
54
|
-
|
55
|
-
assert_equal klass.range_hash_to_str({columns: :all, rows: :all}, num_columns, num_rows), "A1:Z10"
|
56
|
-
|
57
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeValue do
|
58
|
-
assert_equal klass.range_hash_to_str({columns: ('foobar'..'asd'), rows: (1..3)}, num_columns, num_rows), "foobar1:asd3"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
test "verify_range" do
|
63
|
-
num_rows = 10
|
64
|
-
|
65
|
-
klass.verify_range("A1:Z10", num_rows)
|
66
|
-
|
67
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeError do
|
68
|
-
klass.verify_range(:foo, num_rows)
|
69
|
-
end
|
70
|
-
|
71
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeError do
|
72
|
-
klass.verify_range("A1Z10", num_rows)
|
73
|
-
end
|
74
|
-
|
75
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidRangeValue do
|
76
|
-
klass.verify_range("A1:A#{num_rows+1}", num_rows)
|
77
|
-
end
|
78
|
-
|
79
|
-
klass.verify_range("A1:AAA1", num_rows)
|
80
|
-
end
|
81
|
-
|
82
|
-
test "verify_column" do
|
83
|
-
num_columns = 26
|
84
|
-
|
85
|
-
klass.verify_column(1, num_columns)
|
86
|
-
|
87
|
-
klass.verify_column("A", num_columns)
|
88
|
-
|
89
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
|
90
|
-
klass.verify_column(-1, num_columns)
|
91
|
-
end
|
92
|
-
|
93
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
|
94
|
-
klass.verify_column(99, num_columns)
|
95
|
-
end
|
96
|
-
|
97
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
|
98
|
-
klass.verify_column("foobar", num_columns)
|
99
|
-
end
|
100
|
-
|
101
|
-
assert_raise SpreadsheetArchitect::Exceptions::InvalidColumnError do
|
102
|
-
klass.verify_column([], num_columns)
|
103
|
-
end
|
104
|
-
|
105
|
-
klass.verify_column("ZZ", num_columns)
|
106
|
-
end
|
107
|
-
|
108
|
-
test "constants" do
|
109
|
-
assert_equal klass::COL_NAMES.count, 16384
|
110
|
-
assert_equal klass::COL_NAMES.first, 'A'
|
111
|
-
assert_equal klass::COL_NAMES.last, 'XFD'
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
@@ -1,197 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SpreadsheetArchitectUtilsTest < ActiveSupport::TestCase
|
4
|
-
klass = SpreadsheetArchitect::Utils
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@options = {
|
8
|
-
header_style: {background_color: 'AAAAAA', color: 'FFFFFF', align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
|
9
|
-
row_style: {background_color: nil, color: '000000', align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
|
10
|
-
sheet_name: 'My Project Export',
|
11
|
-
column_styles: [],
|
12
|
-
range_styles: [],
|
13
|
-
merges: [],
|
14
|
-
borders: [],
|
15
|
-
column_types: [],
|
16
|
-
column_widths: [],
|
17
|
-
|
18
|
-
headers: ['test1', 'test2','test3'],
|
19
|
-
data: [
|
20
|
-
['row1'],
|
21
|
-
['row2 c1', 'row2 c2'],
|
22
|
-
['the','data']
|
23
|
-
]
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def teardown
|
28
|
-
end
|
29
|
-
|
30
|
-
test "get_cell_data" do
|
31
|
-
assert klass.get_cell_data(@options, SpreadsheetArchitect)
|
32
|
-
|
33
|
-
assert klass.get_cell_data(@options, Post)
|
34
|
-
|
35
|
-
assert klass.get_options({}, SpreadsheetArchitect)
|
36
|
-
|
37
|
-
assert_raise SpreadsheetArchitect::Exceptions::MultipleDataSourcesError do
|
38
|
-
klass.get_cell_data(@options.merge(instances: []), SpreadsheetArchitect)
|
39
|
-
end
|
40
|
-
|
41
|
-
### using Data option
|
42
|
-
output = klass.get_cell_data(@options.merge(headers: true), SpreadsheetArchitect)
|
43
|
-
assert_equal false, output[:headers]
|
44
|
-
|
45
|
-
output = klass.get_cell_data(@options.merge(headers: false), SpreadsheetArchitect)
|
46
|
-
assert_equal false, output[:headers]
|
47
|
-
|
48
|
-
output = klass.get_cell_data(@options.merge(column_types: nil), SpreadsheetArchitect)
|
49
|
-
assert_nil output[:column_types]
|
50
|
-
|
51
|
-
output = klass.get_cell_data(@options.merge(column_types: []), SpreadsheetArchitect)
|
52
|
-
assert_nil output[:column_types]
|
53
|
-
|
54
|
-
output = klass.get_cell_data(@options.merge(column_types: [:string]), SpreadsheetArchitect)
|
55
|
-
assert_equal output[:column_types], [:string]
|
56
|
-
|
57
|
-
headers = [[1,2,3], [3,4,5]]
|
58
|
-
output = klass.get_cell_data(@options.merge(headers: headers), SpreadsheetArchitect)
|
59
|
-
assert_equal headers, output[:headers]
|
60
|
-
|
61
|
-
### Using instances option
|
62
|
-
output = klass.get_cell_data(@options.merge(data: nil), Post.all)
|
63
|
-
assert output[:instances].is_a?(Array)
|
64
|
-
|
65
|
-
output = klass.get_cell_data(@options.merge(data: nil), Post.limit(0))
|
66
|
-
assert output[:instances].is_a?(Array)
|
67
|
-
|
68
|
-
assert_raise SpreadsheetArchitect::Exceptions::NoDataError do
|
69
|
-
klass.get_cell_data(@options.merge(data: nil, instances: nil), SpreadsheetArchitect)
|
70
|
-
end
|
71
|
-
|
72
|
-
output = klass.get_cell_data(@options.merge(data: nil, instances: [PlainRubyObject.new]), SpreadsheetArchitect)
|
73
|
-
assert output[:instances].count == 1
|
74
|
-
end
|
75
|
-
|
76
|
-
test "get_options" do
|
77
|
-
### Empty
|
78
|
-
assert_not_empty klass.get_options({}, SpreadsheetArchitect)
|
79
|
-
|
80
|
-
### using SpreadsheetArchitect
|
81
|
-
assert_not_empty klass.get_options(@options, SpreadsheetArchitect)
|
82
|
-
|
83
|
-
### with model defaults via SPREADSHEET_OPTIONS
|
84
|
-
assert defined?(CustomPost::SPREADSHEET_OPTIONS)
|
85
|
-
assert klass.get_options(@options, CustomPost)
|
86
|
-
|
87
|
-
### without model defaults via SPREADSHEET_OPTIONS
|
88
|
-
assert_not_empty klass.get_options(@options, Post)
|
89
|
-
|
90
|
-
### without :headers removes :header_style
|
91
|
-
assert_nil klass.get_options({header_style: false, headers: false}, SpreadsheetArchitect)[:header_style]
|
92
|
-
|
93
|
-
### sets :sheet_name if needed
|
94
|
-
assert_equal klass.get_options({sheet_name: false}, SpreadsheetArchitect)[:sheet_name], 'Sheet1'
|
95
|
-
|
96
|
-
### sets :sheet_name if needed, using pluralized only when using Rails
|
97
|
-
assert_equal klass.get_options({sheet_name: false}, Post)[:sheet_name], 'Posts'
|
98
|
-
|
99
|
-
### sets :escape_formulas if not given
|
100
|
-
assert_equal klass.get_options({}, SpreadsheetArchitect)[:escape_formulas], true
|
101
|
-
|
102
|
-
assert_equal klass.get_options({}, SpreadsheetArchitect)[:use_zero_based_row_index], false
|
103
|
-
|
104
|
-
### removes default styles
|
105
|
-
assert_equal klass.get_options({skip_defaults: true}, SpreadsheetArchitect), {skip_defaults: true, sheet_name: "Sheet1", escape_formulas: true, use_zero_based_row_index: false}
|
106
|
-
assert_equal klass.get_options({skip_defaults: true}, Post), {skip_defaults: true, sheet_name: "Posts", escape_formulas: true, use_zero_based_row_index: false}
|
107
|
-
|
108
|
-
assert_not_equal klass.get_options({skip_defaults: false}, SpreadsheetArchitect), {skip_defaults: true, sheet_name: "Sheet1", escape_formulas: true, use_zero_based_row_index: false}
|
109
|
-
assert_not_equal klass.get_options({skip_defaults: false}, Post), {skip_defaults: true, sheet_name: "Posts", escape_formulas: true, use_zero_based_row_index: false}
|
110
|
-
end
|
111
|
-
|
112
|
-
test "is_ar_model" do
|
113
|
-
assert klass.is_ar_model?(Post)
|
114
|
-
|
115
|
-
assert_not klass.is_ar_model?(SpreadsheetArchitect)
|
116
|
-
end
|
117
|
-
|
118
|
-
test "str_titleize" do
|
119
|
-
assert_equal(klass.str_titleize('my_project_export'), 'My Project Export')
|
120
|
-
assert_equal(klass.str_titleize('My Project Export'), 'My Project Export')
|
121
|
-
assert_equal(klass.str_titleize('TBS report'), 'TBS Report')
|
122
|
-
end
|
123
|
-
|
124
|
-
test "check_option_type" do
|
125
|
-
klass.check_option_type(@options, :data, Array)
|
126
|
-
|
127
|
-
klass.check_option_type(@options, :foo, Array)
|
128
|
-
|
129
|
-
assert_raise SpreadsheetArchitect::Exceptions::OptionTypeError do
|
130
|
-
klass.check_option_type({foo: :bar}, :foo, Array)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
test "verify_option_types" do
|
135
|
-
klass.verify_option_types(@options)
|
136
|
-
|
137
|
-
assert_raise SpreadsheetArchitect::Exceptions::OptionTypeError do
|
138
|
-
klass.verify_option_types(@options.merge({column_widths: :foobar}))
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
test "stringify_keys" do
|
143
|
-
hash = klass.stringify_keys({})
|
144
|
-
assert_empty hash
|
145
|
-
|
146
|
-
hash = klass.stringify_keys({foo: :bar})
|
147
|
-
assert_nil hash[:foo]
|
148
|
-
assert_equal hash['foo'], :bar
|
149
|
-
|
150
|
-
hash = klass.stringify_keys({foo: :bar, 'bar' => :foo})
|
151
|
-
assert_nil hash[:foo]
|
152
|
-
assert_equal hash['foo'], :bar
|
153
|
-
|
154
|
-
hash = klass.stringify_keys({foo: {foo: :bar}})
|
155
|
-
assert_nil hash[:foo]
|
156
|
-
assert_equal hash['foo']['foo'], :bar
|
157
|
-
|
158
|
-
hash = klass.stringify_keys({foo: {foo: {foo: :bar}}})
|
159
|
-
assert_nil hash[:foo]
|
160
|
-
assert_equal hash['foo']['foo']['foo'], :bar
|
161
|
-
|
162
|
-
hash = klass.stringify_keys({foo: {foo: {foo: {foo: :bar}}}})
|
163
|
-
assert_nil hash[:foo]
|
164
|
-
assert_equal hash['foo']['foo']['foo']['foo'], :bar
|
165
|
-
end
|
166
|
-
|
167
|
-
test "symbolize_keys" do
|
168
|
-
hash = klass.symbolize_keys({})
|
169
|
-
assert_empty hash
|
170
|
-
|
171
|
-
hash = klass.symbolize_keys({'foo' => :bar})
|
172
|
-
assert_nil hash['foo']
|
173
|
-
assert_equal hash[:foo], :bar
|
174
|
-
|
175
|
-
hash = klass.symbolize_keys({'foo' => :bar, bar: :foo})
|
176
|
-
assert_nil hash['foo']
|
177
|
-
assert_equal hash[:foo], :bar
|
178
|
-
|
179
|
-
hash = klass.symbolize_keys({'foo' => {'foo' => :bar}})
|
180
|
-
assert_nil hash['foo']
|
181
|
-
assert_equal hash[:foo][:foo], :bar
|
182
|
-
|
183
|
-
hash = klass.symbolize_keys({'foo' => {'foo' => {'foo' => :bar}}})
|
184
|
-
assert_nil hash['foo']
|
185
|
-
assert_equal hash[:foo][:foo][:foo], :bar
|
186
|
-
end
|
187
|
-
|
188
|
-
test "hash_array_symbolize_keys" do
|
189
|
-
array = klass.hash_array_symbolize_keys([])
|
190
|
-
assert_empty array
|
191
|
-
|
192
|
-
array = klass.hash_array_symbolize_keys([{'foo' => :bar}])
|
193
|
-
assert_nil array[0]['foo']
|
194
|
-
assert_equal array[0][:foo], :bar
|
195
|
-
end
|
196
|
-
|
197
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class XlsxFreezeTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@options = {
|
7
|
-
headers: [
|
8
|
-
['Latest Posts'],
|
9
|
-
['Title','Category','Author','Posted on','Posted At','Earnings']
|
10
|
-
],
|
11
|
-
data: 50.times.map{|i| [i, "foobar-#{i}", 5.4*i, true, Date.today, Time.now]},
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
def teardown
|
16
|
-
end
|
17
|
-
|
18
|
-
test "basic" do
|
19
|
-
opts = @options.merge({
|
20
|
-
freeze: {rows: 1, columns: 1},
|
21
|
-
})
|
22
|
-
|
23
|
-
# Using Array Data
|
24
|
-
file_data = SpreadsheetArchitect.to_xlsx(opts)
|
25
|
-
|
26
|
-
save_file("xlsx/freeze_basic.xlsx", file_data)
|
27
|
-
end
|
28
|
-
|
29
|
-
test "using_ranges" do
|
30
|
-
opts = @options.merge({
|
31
|
-
freeze: {rows: (2..4), columns: (2..4)},
|
32
|
-
})
|
33
|
-
|
34
|
-
# Using Array Data
|
35
|
-
file_data = SpreadsheetArchitect.to_xlsx(opts)
|
36
|
-
|
37
|
-
save_file("xlsx/freeze_using_ranges.xlsx", file_data)
|
38
|
-
end
|
39
|
-
|
40
|
-
test "using_legacy_arguments" do
|
41
|
-
opts = @options.merge({
|
42
|
-
freeze: {rows: :all, columns: 2},
|
43
|
-
})
|
44
|
-
|
45
|
-
# Using Array Data
|
46
|
-
file_data = SpreadsheetArchitect.to_xlsx(opts)
|
47
|
-
|
48
|
-
save_file("xlsx/freeze_using_legacy_arguments.xlsx", file_data)
|
49
|
-
end
|
50
|
-
|
51
|
-
test "freeze_type" do
|
52
|
-
opts = @options.merge({
|
53
|
-
freeze: {row: (@options[:data].size-2), column: 16, type: "split_panes"},
|
54
|
-
})
|
55
|
-
|
56
|
-
# Using Array Data
|
57
|
-
file_data = SpreadsheetArchitect.to_xlsx(opts)
|
58
|
-
|
59
|
-
save_file("xlsx/freeze_type.xlsx", file_data)
|
60
|
-
end
|
61
|
-
|
62
|
-
test "panes_all_axlsx_options" do
|
63
|
-
opts = @options.merge({
|
64
|
-
freeze: {
|
65
|
-
row: (@options[:data].size-2),
|
66
|
-
column: 16,
|
67
|
-
state: "split",
|
68
|
-
#active_pane: "top_right",
|
69
|
-
#top_left_cell: "A2",
|
70
|
-
},
|
71
|
-
})
|
72
|
-
|
73
|
-
# Using Array Data
|
74
|
-
file_data = SpreadsheetArchitect.to_xlsx(opts)
|
75
|
-
|
76
|
-
save_file("xlsx/freeze_panes_all_axlsx_options.xlsx", file_data)
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
@@ -1,199 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class XlsxGeneralTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
describe "header" do
|
6
|
-
test "header: false" do
|
7
|
-
spreadsheet = SpreadsheetArchitect.to_xlsx(headers: false, data: [[1]])
|
8
|
-
|
9
|
-
save_file("xlsx/headers_false_test.xlsx", spreadsheet)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
test "use_zero_based_row_index" do
|
14
|
-
spreadsheet = SpreadsheetArchitect.to_xlsx(
|
15
|
-
use_zero_based_row_index: true,
|
16
|
-
headers: [1, 2, 3],
|
17
|
-
data: [
|
18
|
-
[4,5,6],
|
19
|
-
[7,8,9],
|
20
|
-
[10,11,12],
|
21
|
-
],
|
22
|
-
range_styles: [
|
23
|
-
{range: {rows: 0, columns: 0}, styles: {bold: true}},
|
24
|
-
{range: {rows: (2..3), columns: 0}, styles: {italic: true}},
|
25
|
-
],
|
26
|
-
merges: [
|
27
|
-
{range: {rows: 0, columns: 1..2}},
|
28
|
-
{range: {rows: (2..3), columns: 2}},
|
29
|
-
],
|
30
|
-
borders: [
|
31
|
-
{range: {rows: 0, columns: :all}},
|
32
|
-
{range: {rows: 3, columns: 0}},
|
33
|
-
],
|
34
|
-
)
|
35
|
-
|
36
|
-
save_file("xlsx/use_zero_based_row_index_test.xlsx", spreadsheet)
|
37
|
-
end
|
38
|
-
|
39
|
-
test "multisheet" do
|
40
|
-
test_data = [[1,2,3], [4,5,6], [7,8,9]]
|
41
|
-
|
42
|
-
package = Post.to_axlsx_package
|
43
|
-
package = CustomPost.to_axlsx_package({sheet_name: 'Latest Projects'}, package)
|
44
|
-
package = SpreadsheetArchitect.to_axlsx_package({data: test_data, sheet_name: 'Another Sheet'}, package)
|
45
|
-
|
46
|
-
save_file("xlsx/multi_sheet.xlsx", package)
|
47
|
-
end
|
48
|
-
|
49
|
-
test "kitchen sink" do
|
50
|
-
options = {
|
51
|
-
headers: [
|
52
|
-
['Latest Posts'],
|
53
|
-
['Title','Category','Author','Posted on','Posted At','Earnings']
|
54
|
-
],
|
55
|
-
data: 50.times.map{|i| [i, "foobar-#{i}", 5.4*i, true, Date.today, Time.now]},
|
56
|
-
header_style: {background_color: "000000", color: "FFFFFF", align: :center, font_size: 12, bold: true},
|
57
|
-
row_style: {background_color: nil, color: "000000", align: :left, font_size: 12},
|
58
|
-
sheet_name: 'Kitchen Sink',
|
59
|
-
freeze_headers: true,
|
60
|
-
|
61
|
-
column_styles: [
|
62
|
-
{columns: 0, styles: {bold: true}},
|
63
|
-
{columns: (1..3), styles: {color: "444444"}},
|
64
|
-
{columns: [4], include_header: false, styles: {italic: true}}
|
65
|
-
],
|
66
|
-
|
67
|
-
range_styles: [
|
68
|
-
{range: "B2:C4", styles: {background_color: "CCCCCC"}},
|
69
|
-
{range: {rows: 1, columns: :all}, styles: {bold: true}},
|
70
|
-
{range: {rows: (20..25), columns: (1..4)}, styles: {italic: true}},
|
71
|
-
{range: {rows: :all, columns: (3..4)}, styles: {color: "999999"}}
|
72
|
-
],
|
73
|
-
|
74
|
-
conditional_row_styles: [
|
75
|
-
{
|
76
|
-
if: Proc.new{|row_data, row_index|
|
77
|
-
row_index == 0 || row_data[0].to_i == 2
|
78
|
-
},
|
79
|
-
styles: {font_size: 18}
|
80
|
-
},
|
81
|
-
{
|
82
|
-
unless: Proc.new{|row_data, row_index|
|
83
|
-
row_index <= 10 || row_data[0].to_i == 15
|
84
|
-
},
|
85
|
-
styles: {align: :right}
|
86
|
-
},
|
87
|
-
],
|
88
|
-
|
89
|
-
borders: [
|
90
|
-
{range: "B2:C4"},
|
91
|
-
{range: "D6:D7", border_styles: {style: :dashDot, color: "333333"}},
|
92
|
-
{range: {rows: (2..11), columns: :all}, border_styles: {edges: [:top,:bottom]}},
|
93
|
-
{range: {rows: 3, columns: 4}, border_styles: {edges: [:top,:bottom]}}
|
94
|
-
],
|
95
|
-
|
96
|
-
merges: [
|
97
|
-
{range: "A1:C1"},
|
98
|
-
{range: {rows: 2, columns: :all}},
|
99
|
-
{range: {rows: (3..4), columns: (0..3)}}
|
100
|
-
],
|
101
|
-
|
102
|
-
column_types: [
|
103
|
-
:integer,
|
104
|
-
:string,
|
105
|
-
:float,
|
106
|
-
:boolean,
|
107
|
-
:date,
|
108
|
-
:time,
|
109
|
-
nil,
|
110
|
-
],
|
111
|
-
}
|
112
|
-
|
113
|
-
# Using Array Data
|
114
|
-
file_data = SpreadsheetArchitect.to_xlsx(options)
|
115
|
-
|
116
|
-
save_file("xlsx/kitchen_sink.xlsx", file_data)
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "column_types" do
|
120
|
-
test "validates provided types" do
|
121
|
-
assert_raise SpreadsheetArchitect::Exceptions::ArgumentError do
|
122
|
-
SpreadsheetArchitect.to_axlsx_package(
|
123
|
-
data: [],
|
124
|
-
column_types: [""]
|
125
|
-
)
|
126
|
-
end
|
127
|
-
|
128
|
-
SpreadsheetArchitect.to_axlsx_package(
|
129
|
-
data: [],
|
130
|
-
column_types: [:string, :integer, :float, :date, :time, :boolean, :hyperlink, nil, ->(x){ :foo }]
|
131
|
-
)
|
132
|
-
end
|
133
|
-
|
134
|
-
test "works with Proc types" do
|
135
|
-
url = "https://github.com/westonganger/spreadsheet_architect"
|
136
|
-
|
137
|
-
data = [
|
138
|
-
[1, 2],
|
139
|
-
[1, url],
|
140
|
-
]
|
141
|
-
|
142
|
-
p = SpreadsheetArchitect.to_axlsx_package(
|
143
|
-
data: data,
|
144
|
-
column_types: [
|
145
|
-
:string,
|
146
|
-
->(x){ x.to_s.start_with?("http") ? :hyperlink : :string }
|
147
|
-
]
|
148
|
-
)
|
149
|
-
|
150
|
-
doc = parse_axlsx_package(p)
|
151
|
-
|
152
|
-
hyperlinks = doc.css("hyperlinks hyperlink")
|
153
|
-
|
154
|
-
assert_equal 1, hyperlinks.size
|
155
|
-
|
156
|
-
ref = "B2"
|
157
|
-
assert_equal ref, hyperlinks[0].attr("ref")
|
158
|
-
cell = doc.at("c[r='#{ref}']")
|
159
|
-
assert_equal url, cell.text
|
160
|
-
assert_equal "inlineStr", cell.attr("t")
|
161
|
-
|
162
|
-
save_file("xlsx/hyperlinks.xlsx", p)
|
163
|
-
end
|
164
|
-
|
165
|
-
describe "hyperlinks" do
|
166
|
-
test "shows the text and have the correct attributes" do
|
167
|
-
url = "https://github.com/westonganger/spreadsheet_architect"
|
168
|
-
|
169
|
-
data = [
|
170
|
-
[1,2,3],
|
171
|
-
[1, url, "https://github.com/caxlsx/caxlsx"],
|
172
|
-
]
|
173
|
-
|
174
|
-
p = SpreadsheetArchitect.to_axlsx_package(data: data, column_types: [:string, :hyperlink, :string])
|
175
|
-
|
176
|
-
doc = parse_axlsx_package(p)
|
177
|
-
|
178
|
-
hyperlinks = doc.css("hyperlinks hyperlink")
|
179
|
-
|
180
|
-
assert_equal 2, hyperlinks.size
|
181
|
-
|
182
|
-
ref = "B1"
|
183
|
-
assert_equal ref, hyperlinks[0].attr("ref")
|
184
|
-
cell = doc.at("c[r='#{ref}']")
|
185
|
-
assert_equal "2", cell.text
|
186
|
-
assert_equal "inlineStr", cell.attr("t")
|
187
|
-
|
188
|
-
ref = "B2"
|
189
|
-
assert_equal ref, hyperlinks[1].attr("ref")
|
190
|
-
cell = doc.at("c[r='#{ref}']")
|
191
|
-
assert_equal url, cell.text
|
192
|
-
assert_equal "inlineStr", cell.attr("t")
|
193
|
-
|
194
|
-
save_file("xlsx/hyperlinks.xlsx", p)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
end
|