xlsx2latex 0.1.0.rc1 → 0.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea49d31ba3f4b764257870012ee60ff738e2d078
4
- data.tar.gz: 8beaf03f180091d67940296105c9c9a48e2974f8
3
+ metadata.gz: 29d14be5d7d22b9a22633dfcf506679ccc1c5cc0
4
+ data.tar.gz: f6df11e8155515f4eafb4c0c17654a1debeb3425
5
5
  SHA512:
6
- metadata.gz: f8b47ebfe48c09ab6e84418d629d2a084e14950fb2762e75dc799b49fbca3a6ff18a2c0f464fb0fdfa6a9365bafb393f7561a492cafd7d582e7a186f0b2b4521
7
- data.tar.gz: 0f579ab3d52d1602783baccb87364edfdbe4d33400c639061605eb940a8724e4b757082130d0932b2495630fa55bc567d393f5d4135559338c86c3088201a712
6
+ metadata.gz: 50fb6c0a11784fa946537d7a5dd44e18021647cd1fd7f5d0a705d545929e46cbd4fdeed0dfa967b28587431a6d1f68ae800b0215137de0a96d0129a38bb17b7a
7
+ data.tar.gz: 6102fbb3c7887846f9825ec2b580442f665287caa1b9663526f947b1eeb18ca70832972c2705ccbcb6bddf8a313589786859b5922649ce7d786811b59ef1066c
@@ -12,7 +12,7 @@ Usage: xlsx2latex.exe excelfile [OPTIONS]
12
12
 
13
13
  Options
14
14
  -t, --target TARGET target filename (default STDOUT)
15
- -s, --sheet SHEET Source sheet in Excel
15
+ -s, --sheet SHEET Source sheet in Excel (default: all)
16
16
  -f, --float FLOAT Format for floats
17
17
  -d, --date DATE Format for dates
18
18
  --time TIME Format for times
@@ -36,9 +36,11 @@ Change data format (e.g. to "1. January 2015"):
36
36
  Change format for boolean values:
37
37
  xlsx2latex my_excel.xlsx --true yes --false no
38
38
 
39
- Not supported:
39
+ =======
40
+ Not supported features:
40
41
  * xls-files [1]
41
42
  * deep control on text formats [2]
43
+ * Suppress text formats (make no bold...) [3]
42
44
  * select areas or specific columns for export [3]
43
45
  * column specific formats [3]
44
46
  * Detect number format of Excel and use it for the output [4]
@@ -1,9 +1,8 @@
1
+ #!/usr/bin/env ruby
1
2
  #encoding: utf-8
2
- #!/usr/bin/env
3
3
  =begin rdoc
4
4
  Gem XLSX2LaTeX: Convert excel-files to LaTeX-tabulars.
5
5
  =end
6
-
7
6
  require_relative '../lib/xlsx2latex'
8
7
 
9
8
  require 'optparse'
@@ -19,7 +18,7 @@ opt_parser = OptionParser.new do |opt|
19
18
  options[:target] = target
20
19
  end
21
20
 
22
- opt.on("-s","--sheet SHEET","Source sheet in Excel") do |sheet|
21
+ opt.on("-s","--sheet SHEET","Source sheet in Excel (default: all)") do |sheet|
23
22
  options[:sheet] = sheet
24
23
  end
25
24
 
@@ -106,14 +105,34 @@ if ! File.exist?(ARGV[0])
106
105
  end
107
106
 
108
107
  $excel = XLSX2LaTeX::Excel.new(ARGV[0])
109
- texcode = $excel.to_latex(
110
- sheetname: options[:sheet] || $excel.xlsx.default_sheet,
111
- float_format: options[:float] || '%0.2f',
112
- date_format: options[:date] || '%Y-%m-%d',
113
- time_format: options[:time] || '%Y-%m-%d %H:%M',
114
- bool_true: options[:true] || 'X',
115
- bool_false: options[:false] || '-',
116
- )
108
+ texcode = <<preamble % [File.basename(__FILE__), ARGV[0] ]
109
+ %%encoding: utf-8
110
+ %%%%%%%%%%%%%%%%%%
111
+ %%
112
+ %% LaTeX tabular created by %s
113
+ %% Source: %s
114
+ %%
115
+ %%%%%%%%%%%%%%%%%%
116
+ preamble
117
+ sheets = []
118
+ if options[:sheet]
119
+ sheets << options[:sheet]
120
+ else
121
+ #~ sheets << $excel.xlsx.default_sheet
122
+ sheets = $excel.xlsx.sheets
123
+ end
124
+
125
+ sheets.each do |sheetname|
126
+ texcode << "\n\n%%\n%%Source: %s [%s]\n%%\n" % [ ARGV[0], sheetname]
127
+ texcode << $excel.to_latex(
128
+ sheetname: sheetname,
129
+ float_format: options[:float] || '%0.2f',
130
+ date_format: options[:date] || '%Y-%m-%d',
131
+ time_format: options[:time] || '%Y-%m-%d %H:%M',
132
+ bool_true: options[:true] || 'X',
133
+ bool_false: options[:false] || '-',
134
+ )
135
+ end
117
136
 
118
137
  if options[:target]
119
138
  File.open(options[:target], 'w:utf-8'){|f|
@@ -7,7 +7,7 @@ Gem XLSX2LaTeX: Convert excel-files to LaTeX-tabulars.
7
7
 
8
8
 
9
9
  module XLSX2LaTeX
10
- VERSION = '0.1.0.rc1'
10
+ VERSION = '0.1.0.rc2'
11
11
  end #Xlsx2latex
12
12
 
13
13
  require 'roo'
@@ -36,7 +36,7 @@ The supported options (with defaults):
36
36
  bool_true: 'X', bool_false: '-',
37
37
  log_outputter: Log4r::StdoutOutputter.new('stdout')
38
38
  )
39
-
39
+ @filename = filename
40
40
  @log = Log4r::Logger.new(File.basename(filename))
41
41
  @log.outputters << log_outputter if log_outputter
42
42
  @log.level = Log4r::INFO
@@ -57,6 +57,7 @@ The supported options (with defaults):
57
57
  Call #xlsx.info
58
58
  =end
59
59
  def info; @xlsx.info; end
60
+ def inspect; '<XLSX2LaTeX::Excel %s>' % @filename; end
60
61
  =begin rdoc
61
62
 
62
63
  call-seq:
@@ -3,6 +3,9 @@ Convert excel-files (xlsx) to LaTeX-tabulars.
3
3
 
4
4
  Details see XLSX2LaTeX::Excel
5
5
 
6
+ This gem is located at
7
+ * https://github.com/knut2/xlsx2latex
8
+ * https://rubygems.org/gems/xlsx2latex
6
9
 
7
10
  ==Why?
8
11
  This gem is inpired by a question at
@@ -1,4 +1,17 @@
1
1
  INFO simple.xlsx: Convert Sheet DATA to LaTeX
2
+ INFO simple.xlsx: Convert Sheet DATA2 to LaTeX
3
+ %encoding: utf-8
4
+ %%%%%%%%%
5
+ %
6
+ % LaTeX tabular created by xlsx2latex.rb
7
+ % Source: testdata/simple.xlsx
8
+ %
9
+ %%%%%%%%%
10
+
11
+
12
+ %
13
+ %Source: testdata/simple.xlsx [DATA]
14
+ %
2
15
  \begin{tabular}{c|c|c|c|c|}
3
16
  first & 9.00 & yes & 0.81 & 2015-01-01\\
4
17
  second & 6.00 & no & 0.05 & 2015-01-01\\
@@ -7,3 +20,15 @@ fourth & 23.00 & yes & 0.31 & 2015-01-01\\
7
20
  fifth & 18.00 & no & 0.72 & 2015-01-01\\
8
21
  sixth & 24.00 & no & 0.25 & 2015-01-01
9
22
  \end{tabular}
23
+
24
+ %
25
+ %Source: testdata/simple.xlsx [DATA2]
26
+ %
27
+ \begin{tabular}{c|c|c|}
28
+ sixth & 11.00 & 0.03\\
29
+ fifth & 10.00 & 0.72\\
30
+ fourth & 20.00 & 0.98\\
31
+ third & 16.00 & 0.17\\
32
+ second & 19.00 & 0.04\\
33
+ first & 1.00 & 1.00
34
+ \end{tabular}
@@ -1,4 +1,17 @@
1
1
  INFO simple.xlsx: Convert Sheet DATA to LaTeX
2
+ INFO simple.xlsx: Convert Sheet DATA2 to LaTeX
3
+ %encoding: utf-8
4
+ %%%%%%%%%
5
+ %
6
+ % LaTeX tabular created by xlsx2latex.rb
7
+ % Source: testdata/simple.xlsx
8
+ %
9
+ %%%%%%%%%
10
+
11
+
12
+ %
13
+ %Source: testdata/simple.xlsx [DATA]
14
+ %
2
15
  \begin{tabular}{c|c|c|c|c|}
3
16
  first & 9.00 & X & 0.81 & 01. January 2015\\
4
17
  second & 6.00 & - & 0.05 & 01. January 2015\\
@@ -7,3 +20,15 @@ fourth & 23.00 & X & 0.31 & 01. January 2015\\
7
20
  fifth & 18.00 & - & 0.72 & 01. January 2015\\
8
21
  sixth & 24.00 & - & 0.25 & 01. January 2015
9
22
  \end{tabular}
23
+
24
+ %
25
+ %Source: testdata/simple.xlsx [DATA2]
26
+ %
27
+ \begin{tabular}{c|c|c|}
28
+ sixth & 11.00 & 0.03\\
29
+ fifth & 10.00 & 0.72\\
30
+ fourth & 20.00 & 0.98\\
31
+ third & 16.00 & 0.17\\
32
+ second & 19.00 & 0.04\\
33
+ first & 1.00 & 1.00
34
+ \end{tabular}
@@ -1,4 +1,17 @@
1
1
  INFO simple.xlsx: Convert Sheet DATA to LaTeX
2
+ INFO simple.xlsx: Convert Sheet DATA2 to LaTeX
3
+ %encoding: utf-8
4
+ %%%%%%%%%
5
+ %
6
+ % LaTeX tabular created by xlsx2latex.rb
7
+ % Source: testdata/simple.xlsx
8
+ %
9
+ %%%%%%%%%
10
+
11
+
12
+ %
13
+ %Source: testdata/simple.xlsx [DATA]
14
+ %
2
15
  \begin{tabular}{c|c|c|c|c|}
3
16
  first & 9.00 & X & 0.81 & 2015-01-01\\
4
17
  second & 6.00 & - & 0.05 & 2015-01-01\\
@@ -7,3 +20,15 @@ fourth & 23.00 & X & 0.31 & 2015-01-01\\
7
20
  fifth & 18.00 & - & 0.72 & 2015-01-01\\
8
21
  sixth & 24.00 & - & 0.25 & 2015-01-01
9
22
  \end{tabular}
23
+
24
+ %
25
+ %Source: testdata/simple.xlsx [DATA2]
26
+ %
27
+ \begin{tabular}{c|c|c|}
28
+ sixth & 11.00 & 0.03\\
29
+ fifth & 10.00 & 0.72\\
30
+ fourth & 20.00 & 0.98\\
31
+ third & 16.00 & 0.17\\
32
+ second & 19.00 & 0.04\\
33
+ first & 1.00 & 1.00
34
+ \end{tabular}
@@ -1,4 +1,17 @@
1
1
  INFO simple.xlsx: Convert Sheet DATA to LaTeX
2
+ INFO simple.xlsx: Convert Sheet DATA2 to LaTeX
3
+ %encoding: utf-8
4
+ %%%%%%%%%
5
+ %
6
+ % LaTeX tabular created by xlsx2latex.rb
7
+ % Source: testdata/simple.xlsx
8
+ %
9
+ %%%%%%%%%
10
+
11
+
12
+ %
13
+ %Source: testdata/simple.xlsx [DATA]
14
+ %
2
15
  \begin{tabular}{c|c|c|c|c|}
3
16
  first & 09.000 & X & 00.814 & 2015-01-01\\
4
17
  second & 06.000 & - & 00.054 & 2015-01-01\\
@@ -7,3 +20,15 @@ fourth & 23.000 & X & 00.306 & 2015-01-01\\
7
20
  fifth & 18.000 & - & 00.720 & 2015-01-01\\
8
21
  sixth & 24.000 & - & 00.250 & 2015-01-01
9
22
  \end{tabular}
23
+
24
+ %
25
+ %Source: testdata/simple.xlsx [DATA2]
26
+ %
27
+ \begin{tabular}{c|c|c|}
28
+ sixth & 11.000 & 00.032\\
29
+ fifth & 10.000 & 00.718\\
30
+ fourth & 20.000 & 00.984\\
31
+ third & 16.000 & 00.167\\
32
+ second & 19.000 & 00.039\\
33
+ first & 01.000 & 00.999
34
+ \end{tabular}
@@ -0,0 +1,21 @@
1
+ INFO simple.xlsx: Convert Sheet DATA to LaTeX
2
+ %encoding: utf-8
3
+ %%%%%%%%%
4
+ %
5
+ % LaTeX tabular created by xlsx2latex.rb
6
+ % Source: testdata/simple.xlsx
7
+ %
8
+ %%%%%%%%%
9
+
10
+
11
+ %
12
+ %Source: testdata/simple.xlsx [DATA]
13
+ %
14
+ \begin{tabular}{c|c|c|c|c|}
15
+ first & 9.00 & X & 0.81 & 2015-01-01\\
16
+ second & 6.00 & - & 0.05 & 2015-01-01\\
17
+ third & 8.00 & - & 0.93 & 2015-01-01\\
18
+ fourth & 23.00 & X & 0.31 & 2015-01-01\\
19
+ fifth & 18.00 & - & 0.72 & 2015-01-01\\
20
+ sixth & 24.00 & - & 0.25 & 2015-01-01
21
+ \end{tabular}
@@ -1,4 +1,16 @@
1
1
  INFO simple.xlsx: Convert Sheet DATA2 to LaTeX
2
+ %encoding: utf-8
3
+ %%%%%%%%%
4
+ %
5
+ % LaTeX tabular created by xlsx2latex.rb
6
+ % Source: testdata/simple.xlsx
7
+ %
8
+ %%%%%%%%%
9
+
10
+
11
+ %
12
+ %Source: testdata/simple.xlsx [DATA2]
13
+ %
2
14
  \begin{tabular}{c|c|c|}
3
15
  sixth & 11.00 & 0.03\\
4
16
  fifth & 10.00 & 0.72\\
@@ -1,3 +1,15 @@
1
+ %encoding: utf-8
2
+ %%%%%%%%%
3
+ %
4
+ % LaTeX tabular created by xlsx2latex.rb
5
+ % Source: testdata/simple.xlsx
6
+ %
7
+ %%%%%%%%%
8
+
9
+
10
+ %
11
+ %Source: testdata/simple.xlsx [DATA]
12
+ %
1
13
  \begin{tabular}{c|c|c|c|c|}
2
14
  first & 9.00 & X & 0.81 & 2015-01-01\\
3
15
  second & 6.00 & - & 0.05 & 2015-01-01\\
@@ -5,4 +17,16 @@ third & 8.00 & - & 0.93 & 2015-01-01\\
5
17
  fourth & 23.00 & X & 0.31 & 2015-01-01\\
6
18
  fifth & 18.00 & - & 0.72 & 2015-01-01\\
7
19
  sixth & 24.00 & - & 0.25 & 2015-01-01
20
+ \end{tabular}
21
+
22
+ %
23
+ %Source: testdata/simple.xlsx [DATA2]
24
+ %
25
+ \begin{tabular}{c|c|c|}
26
+ sixth & 11.00 & 0.03\\
27
+ fifth & 10.00 & 0.72\\
28
+ fourth & 20.00 & 0.98\\
29
+ third & 16.00 & 0.17\\
30
+ second & 19.00 & 0.04\\
31
+ first & 1.00 & 1.00
8
32
  \end{tabular}
@@ -13,6 +13,7 @@ class Test_bin < MiniTest::Test
13
13
  def setup
14
14
  #~ @cmd = 'ruby ../bin/xlsx2latex.rb'
15
15
  @cmd = '../bin/xlsx2latex.exe'
16
+ skip('%s not available' % @cmd) unless File.exist?(@cmd)
16
17
  @src = 'testdata/simple.xlsx'
17
18
  @cmd_src = [@cmd, @src].join(' ')
18
19
  end
@@ -41,13 +42,19 @@ class Test_bin < MiniTest::Test
41
42
  assert(File.exist?(filename), "Target file is not created")
42
43
  assert_equal(<<LOG % filename, output)
43
44
  INFO simple.xlsx: Convert Sheet DATA to LaTeX
45
+ INFO simple.xlsx: Convert Sheet DATA2 to LaTeX
44
46
  INFO simple.xlsx: Created %s
45
47
  LOG
46
48
  assert_equal_filecontent('expected/%s.tex' % __method__, File.read(filename))
47
49
  File.delete(filename)
48
50
  end
49
51
 
50
- def test_bin_select_sheet
52
+ def test_bin_select_sheet1
53
+ output = `#{@cmd_src} -s DATA`
54
+ assert_equal(0,$?.exitstatus)
55
+ assert_equal_filecontent('expected/%s.tex' % __method__, output)
56
+ end
57
+ def test_bin_select_sheet2
51
58
  output = `#{@cmd_src} -s DATA2`
52
59
  assert_equal(0,$?.exitstatus)
53
60
  assert_equal_filecontent('expected/%s.tex' % __method__, output)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsx2latex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc1
4
+ version: 0.1.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Knut Lickert
@@ -66,7 +66,10 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2'
69
- description: ''
69
+ description: |
70
+ Take an Excel-file (xlsx) and convert the content into a LaTeX-tabular.
71
+
72
+ By default each tab becomes a tabular.
70
73
  email: knut@lickert.net
71
74
  executables:
72
75
  - xlsx2latex.rb
@@ -93,7 +96,8 @@ files:
93
96
  - unittest/expected/test_bin_date.tex
94
97
  - unittest/expected/test_bin_default.tex
95
98
  - unittest/expected/test_bin_float.tex
96
- - unittest/expected/test_bin_select_sheet.tex
99
+ - unittest/expected/test_bin_select_sheet1.tex
100
+ - unittest/expected/test_bin_select_sheet2.tex
97
101
  - unittest/expected/test_bin_with_target.tex
98
102
  - unittest/expected/test_default_sheet.tex
99
103
  - unittest/expected/test_sheet1.tex
@@ -106,8 +110,9 @@ files:
106
110
  - unittest/testdata/make_testdata.rb
107
111
  - unittest/testdata/simple.xlsx
108
112
  - unittest/testdata/testdata_excel2latex.xlsx
109
- homepage:
110
- licenses: []
113
+ homepage: https://github.com/knut2/xlsx2latex
114
+ licenses:
115
+ - LPPL-1.3c
111
116
  metadata: {}
112
117
  post_install_message:
113
118
  rdoc_options:
@@ -119,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
124
  requirements:
120
125
  - - ">="
121
126
  - !ruby/object:Gem::Version
122
- version: '0'
127
+ version: '2.0'
123
128
  required_rubygems_version: !ruby/object:Gem::Requirement
124
129
  requirements:
125
130
  - - ">"
@@ -130,7 +135,7 @@ rubyforge_project:
130
135
  rubygems_version: 2.4.5
131
136
  signing_key:
132
137
  specification_version: 4
133
- summary: ''
138
+ summary: Convert Excel-file to LaTeX-tabulars
134
139
  test_files:
135
140
  - unittest/test_testdata_excel2latex.rb
136
141
  - unittest/test_generated_xlsx.rb
@@ -151,7 +156,8 @@ test_files:
151
156
  - unittest/expected/test_bin_date.tex
152
157
  - unittest/expected/test_bin_default.tex
153
158
  - unittest/expected/test_bin_float.tex
154
- - unittest/expected/test_bin_select_sheet.tex
159
+ - unittest/expected/test_bin_select_sheet1.tex
160
+ - unittest/expected/test_bin_select_sheet2.tex
155
161
  - unittest/expected/test_bin_with_target.tex
156
162
  - unittest/expected/test_default_sheet.tex
157
163
  - unittest/expected/test_sheet1.tex