workbook 0.2.0 → 0.2.1
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.
- data/.yardoc/checksums +18 -0
- data/.yardoc/object_types +3 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile.lock +1 -1
- data/{readme.markdown → README.md} +36 -10
- data/doc/RubyXL.html +128 -0
- data/doc/RubyXL/Cell.html +202 -0
- data/doc/RubyXL/Workbook.html +447 -0
- data/doc/Workbook.html +130 -0
- data/doc/Workbook/Book.html +1484 -0
- data/doc/Workbook/Cell.html +1402 -0
- data/doc/Workbook/Format.html +654 -0
- data/doc/Workbook/Modules.html +117 -0
- data/doc/Workbook/Modules/RawObjectsStorage.html +508 -0
- data/doc/Workbook/Modules/TableDiffSort.html +620 -0
- data/doc/Workbook/Modules/TypeParser.html +1012 -0
- data/doc/Workbook/Readers.html +117 -0
- data/doc/Workbook/Readers/CsvReader.html +262 -0
- data/doc/Workbook/Readers/TxtReader.html +238 -0
- data/doc/Workbook/Readers/XlsReader.html +362 -0
- data/doc/Workbook/Readers/XlsShared.html +189 -0
- data/doc/Workbook/Readers/XlsxReader.html +295 -0
- data/doc/Workbook/Row.html +1939 -0
- data/doc/Workbook/Sheet.html +528 -0
- data/doc/Workbook/Table.html +883 -0
- data/doc/Workbook/Template.html +639 -0
- data/doc/Workbook/Writers.html +117 -0
- data/doc/Workbook/Writers/CsvTableWriter.html +175 -0
- data/doc/Workbook/Writers/XlsWriter.html +865 -0
- data/doc/_index.html +336 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +236 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +236 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +972 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/workbook/book.rb +38 -29
- data/lib/workbook/cell.rb +25 -0
- data/lib/workbook/format.rb +9 -2
- data/lib/workbook/modules/raw_objects_storage.rb +5 -0
- data/lib/workbook/modules/table_diff_sort.rb +8 -6
- data/lib/workbook/modules/type_parser.rb +16 -3
- data/lib/workbook/readers/xls_reader.rb +1 -70
- data/lib/workbook/readers/xls_shared.rb +75 -0
- data/lib/workbook/row.rb +89 -17
- data/lib/workbook/sheet.rb +26 -0
- data/lib/workbook/table.rb +20 -1
- data/lib/workbook/template.rb +12 -11
- data/lib/workbook/writers/xls_writer.rb +19 -77
- data/test/test_modules_table_diff_sort.rb +19 -6
- data/test/test_row.rb +54 -0
- data/test/test_sheet.rb +8 -0
- data/test/test_table.rb +22 -3
- data/test/test_writers_xls_writer.rb +3 -0
- data/workbook.gemspec +1 -1
- metadata +46 -3
data/doc/file_list.html
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
|
7
|
+
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
|
+
|
17
|
+
|
18
|
+
<base id="base_target" target="_parent" />
|
19
|
+
</head>
|
20
|
+
<body>
|
21
|
+
<script type="text/javascript" charset="utf-8">
|
22
|
+
if (window.top.frames.main) {
|
23
|
+
document.getElementById('base_target').target = 'main';
|
24
|
+
document.body.className = 'frames';
|
25
|
+
}
|
26
|
+
</script>
|
27
|
+
<div id="content">
|
28
|
+
<h1 id="full_list_header">File List</h1>
|
29
|
+
<div id="nav">
|
30
|
+
|
31
|
+
<span><a target="_self" href="class_list.html">
|
32
|
+
Classes
|
33
|
+
</a></span>
|
34
|
+
|
35
|
+
<span><a target="_self" href="method_list.html">
|
36
|
+
Methods
|
37
|
+
</a></span>
|
38
|
+
|
39
|
+
<span><a target="_self" href="file_list.html">
|
40
|
+
Files
|
41
|
+
</a></span>
|
42
|
+
|
43
|
+
</div>
|
44
|
+
<div id="search">Search: <input type="text" /></div>
|
45
|
+
|
46
|
+
<ul id="full_list" class="file">
|
47
|
+
|
48
|
+
|
49
|
+
<li class="r1"><a href="index.html" title="README">README</a></li>
|
50
|
+
|
51
|
+
|
52
|
+
</ul>
|
53
|
+
</div>
|
54
|
+
</body>
|
55
|
+
</html>
|
data/doc/frames.html
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
+
<title>Documentation by YARD 0.8.3</title>
|
8
|
+
</head>
|
9
|
+
<script type="text/javascript" charset="utf-8">
|
10
|
+
window.onload = function() {
|
11
|
+
var match = window.location.hash.match(/^#!(.+)/);
|
12
|
+
var name = 'index.html';
|
13
|
+
if (match) {
|
14
|
+
name = unescape(match[1]);
|
15
|
+
}
|
16
|
+
document.writeln('<frameset cols="20%,*">' +
|
17
|
+
'<frame name="list" src="class_list.html" />' +
|
18
|
+
'<frame name="main" src="' + name + '" />' +
|
19
|
+
'</frameset>');
|
20
|
+
}
|
21
|
+
</script>
|
22
|
+
<noscript>
|
23
|
+
<frameset cols="20%,*">
|
24
|
+
<frame name="list" src="class_list.html" />
|
25
|
+
<frame name="main" src="index.html" />
|
26
|
+
</frameset>
|
27
|
+
</noscript>
|
28
|
+
</html>
|
data/doc/index.html
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
File: README
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.3
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="_index.html">Index</a> »
|
35
|
+
<span class="title">File: README</span>
|
36
|
+
|
37
|
+
|
38
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search">
|
42
|
+
|
43
|
+
<a class="full_list_link" id="class_list_link"
|
44
|
+
href="class_list.html">
|
45
|
+
Class List
|
46
|
+
</a>
|
47
|
+
|
48
|
+
<a class="full_list_link" id="method_list_link"
|
49
|
+
href="method_list.html">
|
50
|
+
Method List
|
51
|
+
</a>
|
52
|
+
|
53
|
+
<a class="full_list_link" id="file_list_link"
|
54
|
+
href="file_list.html">
|
55
|
+
File List
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<iframe id="search_frame"></iframe>
|
63
|
+
|
64
|
+
<div id="content"><div id='filecontents'><h1 id="workbook">Workbook</h1>
|
65
|
+
|
66
|
+
<p>Goal of this gem is to make working with workbooks (spreadsheets) as programmer friendly as possible. Not reinventing a totally new DSL or all kinds of new methodnames, but just borrowing from known concepts such as hashes and arrays (much like (Faster)CSV does)). Workbook is a gem that mimicks a typical spreadsheet, a bundle of sheets, bundled in a <em>workbook</em>. A sheet may contain one or more tables (which might the multi table sheets of Apple Numbers or Excel ranges). Basically:</p>
|
67
|
+
|
68
|
+
<ul>
|
69
|
+
<li>Book
|
70
|
+
<ul>
|
71
|
+
<li>Sheet (one or more)
|
72
|
+
<ul>
|
73
|
+
<li>Table (one or more)</li>
|
74
|
+
</ul>
|
75
|
+
</li>
|
76
|
+
</ul>
|
77
|
+
</li>
|
78
|
+
</ul>
|
79
|
+
|
80
|
+
<p>Subsequently a table consists of:</p>
|
81
|
+
|
82
|
+
<ul>
|
83
|
+
<li>Table
|
84
|
+
<ul>
|
85
|
+
<li>Row (one or more)
|
86
|
+
<ul>
|
87
|
+
<li>Cell ( wich has may have a (shared) Format )</li>
|
88
|
+
</ul>
|
89
|
+
</li>
|
90
|
+
</ul>
|
91
|
+
</li>
|
92
|
+
</ul>
|
93
|
+
|
94
|
+
<p>Book, Sheet, Table and Row inherit from the base Array class, and hence walks and quacks as such. The row is extended with hashlike lookups (<code>row[:id]</code>) and writers (<code>row[:id]=</code>). Values are converted to ruby native types, and optional parsers can be added to improve recognition. </p>
|
95
|
+
|
96
|
+
<p>In addition to offering you this plain structure it allows for importing .xls, .csv, .xlsx, .txt files (more to come), writing .xls, and .csv (more to come) and includes several utilities to easily create an overview of the differences between two tables and output basic cell-styling properties as css.</p>
|
97
|
+
|
98
|
+
<h2 id="the-basics">The Basics</h2>
|
99
|
+
|
100
|
+
<p>Simply initialize a simple spreadsheet using:</p>
|
101
|
+
|
102
|
+
<pre class="code ruby"><code><span class='rubyid_b identifier id'>b</span> <span class='assign token'>=</span> <span class='rubyid_Workbook constant id'>Workbook</span><span class='colon2 op'>::</span><span class='rubyid_Book constant id'>Book</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span>
|
103
|
+
</code></pre>
|
104
|
+
|
105
|
+
<p>or</p>
|
106
|
+
|
107
|
+
<pre class="code ruby"><code><span class='rubyid_b identifier id'>b</span> <span class='assign token'>=</span> <span class='rubyid_Workbook constant id'>Workbook</span><span class='colon2 op'>::</span><span class='rubyid_Book constant id'>Book</span><span class='dot token'>.</span><span class='rubyid_open identifier id'>open</span> <span class='rubyid_filename identifier id'>filename</span>
|
108
|
+
</code></pre>
|
109
|
+
|
110
|
+
<p>Calling</p>
|
111
|
+
|
112
|
+
<pre class="code ruby"><code><span class='rubyid_s identifier id'>s</span> <span class='assign token'>=</span> <span class='rubyid_b identifier id'>b</span><span class='dot token'>.</span><span class='rubyid_sheet identifier id'>sheet</span>
|
113
|
+
<span class='rubyid_t identifier id'>t</span> <span class='assign token'>=</span> <span class='rubyid_s identifier id'>s</span><span class='dot token'>.</span><span class='rubyid_table identifier id'>table</span>
|
114
|
+
</code></pre>
|
115
|
+
|
116
|
+
<p>will give you an the first Sheet and Table (if one doesn’t exist it is created on the fly).</p>
|
117
|
+
|
118
|
+
<p>You can initialize with simple 2-d array like this:</p>
|
119
|
+
|
120
|
+
<pre class="code ruby"><code><span class='rubyid_b identifier id'>b</span> <span class='assign token'>=</span> <span class='rubyid_Workbook constant id'>Workbook</span><span class='colon2 op'>::</span><span class='rubyid_Book constant id'>Book</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span> <span class='lbrack token'>[</span><span class='lbrack token'>[</span><span class='string val'>'a'</span><span class='comma token'>,</span><span class='string val'>'b'</span><span class='rbrack token'>]</span><span class='comma token'>,</span><span class='lbrack token'>[</span><span class='integer val'>1</span><span class='comma token'>,</span><span class='integer val'>2</span><span class='rbrack token'>]</span><span class='comma token'>,</span><span class='lbrack token'>[</span><span class='integer val'>3</span><span class='comma token'>,</span><span class='integer val'>4</span><span class='rbrack token'>]</span><span class='comma token'>,</span><span class='lbrack token'>[</span><span class='integer val'>5</span><span class='comma token'>,</span><span class='integer val'>6</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span>
|
121
|
+
<span class='rubyid_t identifier id'>t</span> <span class='assign token'>=</span> <span class='rubyid_s identifier id'>s</span><span class='dot token'>.</span><span class='rubyid_sheet identifier id'>sheet</span><span class='dot token'>.</span><span class='rubyid_table identifier id'>table</span>
|
122
|
+
</code></pre>
|
123
|
+
|
124
|
+
<p>Subsequently you look up values in the table like this:</p>
|
125
|
+
|
126
|
+
<pre class="code ruby"><code><span class='rubyid_t identifier id'>t</span><span class='lbrack token'>[</span><span class='integer val'>1</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='symbol val'>:b</span><span class='rbrack token'>]</span>
|
127
|
+
<span class='comment val'># returns <Workbook::Cel @value=2></span>
|
128
|
+
</code></pre>
|
129
|
+
|
130
|
+
<p>which is equivalent to</p>
|
131
|
+
|
132
|
+
<pre class="code ruby"><code><span class='rubyid_t identifier id'>t</span><span class='lbrack token'>[</span><span class='integer val'>1</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='integer val'>1</span><span class='rbrack token'>]</span>
|
133
|
+
</code></pre>
|
134
|
+
|
135
|
+
<p>Of course you’ll be able to write a new value back to it. If you just enter a value, formatting of the original cell will be maintained.</p>
|
136
|
+
|
137
|
+
<pre class="code ruby"><code><span class='rubyid_t identifier id'>t</span><span class='lbrack token'>[</span><span class='integer val'>1</span><span class='rbrack token'>]</span><span class='lbrack token'>[</span><span class='symbol val'>:b</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='integer val'>5</span>
|
138
|
+
</code></pre>
|
139
|
+
|
140
|
+
<p>If you want to use an existing file as a template (which you can create in Excel to create nice looking templates),
|
141
|
+
simply clone the row, and add it back:</p>
|
142
|
+
|
143
|
+
<pre class="code ruby"><code><span class='rubyid_b identifier id'>b</span> <span class='assign token'>=</span> <span class='rubyid_Workbook constant id'>Workbook</span><span class='colon2 op'>::</span><span class='rubyid_Book constant id'>Book</span><span class='dot token'>.</span><span class='rubyid_open identifier id'>open</span><span class='lparen token'>(</span><span class='string val'>"template.xls"</span><span class='rparen token'>)</span>
|
144
|
+
<span class='rubyid_table identifier id'>table</span> <span class='assign token'>=</span> <span class='rubyid_b identifier id'>b</span><span class='dot token'>.</span><span class='rubyid_sheet identifier id'>sheet</span><span class='dot token'>.</span><span class='rubyid_table identifier id'>table</span>
|
145
|
+
<span class='rubyid_template_row identifier id'>template_row</span> <span class='assign token'>=</span> <span class='rubyid_table identifier id'>table</span><span class='lbrack token'>[</span><span class='integer val'>1</span><span class='rbrack token'>]</span> <span class='comment val'># can be any, but I typically have a well</span>
|
146
|
+
<span class='comment val'># formatted header row + an example template </span>
|
147
|
+
<span class='comment val'># row for the data</span>
|
148
|
+
<span class='lbrack token'>[</span><span class='integer val'>1</span><span class='comma token'>,</span><span class='integer val'>2</span><span class='comma token'>,</span><span class='integer val'>3</span><span class='comma token'>,</span><span class='integer val'>4</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='rubyid_each identifier id'>each</span> <span class='rubyid_do do kw'>do</span> <span class='bitor op'>|</span><span class='rubyid_v identifier id'>v</span><span class='bitor op'>|</span>
|
149
|
+
<span class='rubyid_new_row identifier id'>new_row</span> <span class='assign token'>=</span> <span class='rubyid_template_row identifier id'>template_row</span><span class='dot token'>.</span><span class='rubyid_clone identifier id'>clone</span>
|
150
|
+
<span class='rubyid_table identifier id'>table</span> <span class='lshft op'><<</span> <span class='rubyid_new_row identifier id'>new_row</span> <span class='comment val'># to use the symbol style header references, </span>
|
151
|
+
<span class='comment val'># the row first needs to be added back to the </span>
|
152
|
+
<span class='comment val'># table</span>
|
153
|
+
<span class='rubyid_new_row identifier id'>new_row</span><span class='lbrack token'>[</span><span class='symbol val'>:a</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='rubyid_v identifier id'>v</span>
|
154
|
+
<span class='rubyid_end end kw'>end</span>
|
155
|
+
<span class='rubyid_table identifier id'>table</span><span class='dot token'>.</span><span class='rubyid_delete identifier id'>delete</span><span class='lparen token'>(</span><span class='rubyid_template_row identifier id'>template_row</span><span class='rparen token'>)</span> <span class='comment val'># you don't want the template to show up</span>
|
156
|
+
<span class='comment val'># in the endresult</span>
|
157
|
+
<span class='rubyid_b identifier id'>b</span><span class='dot token'>.</span><span class='rubyid_write identifier id'>write</span><span class='lparen token'>(</span><span class='string val'>"result.xls"</span><span class='rparen token'>)</span> <span class='comment val'># write it!</span>
|
158
|
+
</code></pre>
|
159
|
+
|
160
|
+
<!-- Feature *to implement*:
|
161
|
+
|
162
|
+
t['A2']
|
163
|
+
# returns <Workbook::Cel @value=1>
|
164
|
+
|
165
|
+
Feature *to implement*, get a single column:
|
166
|
+
|
167
|
+
t[:b]
|
168
|
+
# returns [<Workbook::Cel @value=2>,<Workbook::Cel @value=4>,<Workbook::Cel @value=6>]
|
169
|
+
|
170
|
+
On my wishlist: In the future I hope to return the cell value directly, without the intermediate Workbook::Cel class in between.
|
171
|
+
|
172
|
+
-->
|
173
|
+
|
174
|
+
<h2 id="utilities">Utilities</h2>
|
175
|
+
|
176
|
+
<h3 id="sorting">Sorting</h3>
|
177
|
+
|
178
|
+
<p>Sorting leaves the header alone, if it exists, and doesn’t complain about comparing strings with dates with floats (Ever found OpenOffice Calc or Excel complainging about its inability to compare integers and strings? We’re talking spreadsheet here). When classes are different the following (default) order is used: Numbers, Strings, Dates and Times, Booleans and Nils (empty values).</p>
|
179
|
+
|
180
|
+
<pre class="code ruby"><code><span class='rubyid_t identifier id'>t</span><span class='dot token'>.</span><span class='rubyid_sort identifier id'>sort</span>
|
181
|
+
</code></pre>
|
182
|
+
|
183
|
+
<p><em>To implement</em>:</p>
|
184
|
+
|
185
|
+
<p>To some extent, sort_by works, it doesn’t, however, adhere to the header settings… </p>
|
186
|
+
|
187
|
+
<pre class="code ruby"><code><span class='rubyid_t identifier id'>t</span><span class='dot token'>.</span><span class='rubyid_sort_by identifier id'>sort_by</span> <span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='rubyid_r identifier id'>r</span><span class='bitor op'>|</span> <span class='rubyid_r identifier id'>r</span><span class='lbrack token'>[</span><span class='symbol val'>:b</span><span class='rbrack token'>]</span><span class='rbrace token'>}</span>
|
188
|
+
</code></pre>
|
189
|
+
|
190
|
+
<h3 id="comparing-tables">Comparing tables</h3>
|
191
|
+
|
192
|
+
<p>Simply call on a Workbook::Table</p>
|
193
|
+
|
194
|
+
<pre class="code ruby"><code><span class='rubyid_t1 identifier id'>t1</span><span class='dot token'>.</span><span class='rubyid_diff identifier id'>diff</span> <span class='rubyid_t2 identifier id'>t2</span>
|
195
|
+
</code></pre>
|
196
|
+
|
197
|
+
<p>And a new book with a new sheet/table will be returned containing the differences between the two tables.</p>
|
198
|
+
|
199
|
+
<h2 id="writing">Writing</h2>
|
200
|
+
|
201
|
+
<p>Currently writing is limited to the following formats. Templating support is still limited.</p>
|
202
|
+
|
203
|
+
<pre class="code ruby"><code><span class='rubyid_b identifier id'>b</span><span class='dot token'>.</span><span class='rubyid_to_xls identifier id'>to_xls</span> <span class='comment val'># returns a spreadsheet workbook</span>
|
204
|
+
<span class='rubyid_b identifier id'>b</span><span class='dot token'>.</span><span class='rubyid_write_to_xls identifier id'>write_to_xls</span> <span class='rubyid_filename identifier id'>filename</span> <span class='comment val'># writes to filename</span>
|
205
|
+
<span class='rubyid_t identifier id'>t</span><span class='dot token'>.</span><span class='rubyid_to_csv identifier id'>to_csv</span> <span class='comment val'># returns a csv-string (called on tables)</span>
|
206
|
+
</code></pre>
|
207
|
+
|
208
|
+
<p>In case you want to display the table in HTML, some conversion is offered to convert text/background properties to css-entities. Internally the hash storing style elements tries to map to CSS where possible.</p>
|
209
|
+
|
210
|
+
<h2 id="alternatives">Alternatives</h2>
|
211
|
+
|
212
|
+
<p>The <a href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=spreadsheet">ruby toolbox lists plenty of alternatives</a>, that just didn’t suit my needs.</p>
|
213
|
+
|
214
|
+
<h2 id="license">License</h2>
|
215
|
+
|
216
|
+
<p>This code MIT (but see below) (c) murb / Maarten Brouwers, 2011-2013</p>
|
217
|
+
|
218
|
+
<p>Workbook uses the following gems:</p>
|
219
|
+
|
220
|
+
<ul>
|
221
|
+
<li><a href="https://github.com/zdavatz/spreadsheet">Spreadsheet</a> Used for reading and writing old style .xls files (Copyright (c) 2010 ywesee GmbH (mhatakeyama@ywesee.com, zdavatz@ywesee.com); GPL3 (License required for closed implementations))</li>
|
222
|
+
<li><a href="http://code.google.com/p/ruby-ole/">ruby-ole</a> Used in the Spreadsheet Gem (Copyright (c) 2007-2010 Charles Lowe; MIT)</li>
|
223
|
+
<li><a href="http://fastercsv.rubyforge.org/">FasterCSV</a> Used for reading CSV (comma separated text) and TXT (tab separated text) files (Copyright (c) James Edward Gray II; GPL2 & Ruby License)</li>
|
224
|
+
<li><a href="http://rubyforge.org/projects/rchardet">rchardet</a> Used for detecting encoding in CSV and TXT importers (Copyright (c) JMHodges; LGPL)</li>
|
225
|
+
<li><a href="https://github.com/gilt/rubyXL">RubyXL</a> Used for reading the newer .xlsx files (Copyright (c) 2011 Vivek Bhagwat; MIT-Licensed)</li>
|
226
|
+
</ul>
|
227
|
+
</div></div>
|
228
|
+
|
229
|
+
<div id="footer">
|
230
|
+
Generated on Thu Jan 17 13:15:55 2013 by
|
231
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
232
|
+
0.8.3 (ruby-1.8.7).
|
233
|
+
</div>
|
234
|
+
|
235
|
+
</body>
|
236
|
+
</html>
|
data/doc/js/app.js
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
function createSourceLinks() {
|
2
|
+
$('.method_details_list .source_code').
|
3
|
+
before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
|
4
|
+
$('.toggleSource').toggle(function() {
|
5
|
+
$(this).parent().nextAll('.source_code').slideDown(100);
|
6
|
+
$(this).text("Hide source");
|
7
|
+
},
|
8
|
+
function() {
|
9
|
+
$(this).parent().nextAll('.source_code').slideUp(100);
|
10
|
+
$(this).text("View source");
|
11
|
+
});
|
12
|
+
}
|
13
|
+
|
14
|
+
function createDefineLinks() {
|
15
|
+
var tHeight = 0;
|
16
|
+
$('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
|
17
|
+
$('.toggleDefines').toggle(function() {
|
18
|
+
tHeight = $(this).parent().prev().height();
|
19
|
+
$(this).prev().show();
|
20
|
+
$(this).parent().prev().height($(this).parent().height());
|
21
|
+
$(this).text("(less)");
|
22
|
+
},
|
23
|
+
function() {
|
24
|
+
$(this).prev().hide();
|
25
|
+
$(this).parent().prev().height(tHeight);
|
26
|
+
$(this).text("more...");
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
function createFullTreeLinks() {
|
31
|
+
var tHeight = 0;
|
32
|
+
$('.inheritanceTree').toggle(function() {
|
33
|
+
tHeight = $(this).parent().prev().height();
|
34
|
+
$(this).parent().toggleClass('showAll');
|
35
|
+
$(this).text("(hide)");
|
36
|
+
$(this).parent().prev().height($(this).parent().height());
|
37
|
+
},
|
38
|
+
function() {
|
39
|
+
$(this).parent().toggleClass('showAll');
|
40
|
+
$(this).parent().prev().height(tHeight);
|
41
|
+
$(this).text("show all");
|
42
|
+
});
|
43
|
+
}
|
44
|
+
|
45
|
+
function fixBoxInfoHeights() {
|
46
|
+
$('dl.box dd.r1, dl.box dd.r2').each(function() {
|
47
|
+
$(this).prev().height($(this).height());
|
48
|
+
});
|
49
|
+
}
|
50
|
+
|
51
|
+
function searchFrameLinks() {
|
52
|
+
$('.full_list_link').click(function() {
|
53
|
+
toggleSearchFrame(this, $(this).attr('href'));
|
54
|
+
return false;
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
58
|
+
function toggleSearchFrame(id, link) {
|
59
|
+
var frame = $('#search_frame');
|
60
|
+
$('#search a').removeClass('active').addClass('inactive');
|
61
|
+
if (frame.attr('src') == link && frame.css('display') != "none") {
|
62
|
+
frame.slideUp(100);
|
63
|
+
$('#search a').removeClass('active inactive');
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
$(id).addClass('active').removeClass('inactive');
|
67
|
+
frame.attr('src', link).slideDown(100);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
function linkSummaries() {
|
72
|
+
$('.summary_signature').click(function() {
|
73
|
+
document.location = $(this).find('a').attr('href');
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
77
|
+
function framesInit() {
|
78
|
+
if (hasFrames) {
|
79
|
+
document.body.className = 'frames';
|
80
|
+
$('#menu .noframes a').attr('href', document.location);
|
81
|
+
window.top.document.title = $('html head title').text();
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
$('#menu .noframes a').text('frames').attr('href', framesUrl);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
function keyboardShortcuts() {
|
89
|
+
if (window.top.frames.main) return;
|
90
|
+
$(document).keypress(function(evt) {
|
91
|
+
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
|
92
|
+
if (typeof evt.target !== "undefined" &&
|
93
|
+
(evt.target.nodeName == "INPUT" ||
|
94
|
+
evt.target.nodeName == "TEXTAREA")) return;
|
95
|
+
switch (evt.charCode) {
|
96
|
+
case 67: case 99: $('#class_list_link').click(); break; // 'c'
|
97
|
+
case 77: case 109: $('#method_list_link').click(); break; // 'm'
|
98
|
+
case 70: case 102: $('#file_list_link').click(); break; // 'f'
|
99
|
+
default: break;
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
function summaryToggle() {
|
105
|
+
$('.summary_toggle').click(function() {
|
106
|
+
if (localStorage) {
|
107
|
+
localStorage.summaryCollapsed = $(this).text();
|
108
|
+
}
|
109
|
+
$('.summary_toggle').each(function() {
|
110
|
+
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
|
111
|
+
var next = $(this).parent().parent().nextAll('ul.summary').first();
|
112
|
+
if (next.hasClass('compact')) {
|
113
|
+
next.toggle();
|
114
|
+
next.nextAll('ul.summary').first().toggle();
|
115
|
+
}
|
116
|
+
else if (next.hasClass('summary')) {
|
117
|
+
var list = $('<ul class="summary compact" />');
|
118
|
+
list.html(next.html());
|
119
|
+
list.find('.summary_desc, .note').remove();
|
120
|
+
list.find('a').each(function() {
|
121
|
+
$(this).html($(this).find('strong').html());
|
122
|
+
$(this).parent().html($(this)[0].outerHTML);
|
123
|
+
});
|
124
|
+
next.before(list);
|
125
|
+
next.toggle();
|
126
|
+
}
|
127
|
+
});
|
128
|
+
return false;
|
129
|
+
});
|
130
|
+
if (localStorage) {
|
131
|
+
if (localStorage.summaryCollapsed == "collapse") {
|
132
|
+
$('.summary_toggle').first().click();
|
133
|
+
}
|
134
|
+
else localStorage.summaryCollapsed = "expand";
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
function fixOutsideWorldLinks() {
|
139
|
+
$('a').each(function() {
|
140
|
+
if (window.location.host != this.host) this.target = '_parent';
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
function generateTOC() {
|
145
|
+
if ($('#filecontents').length === 0) return;
|
146
|
+
var _toc = $('<ol class="top"></ol>');
|
147
|
+
var show = false;
|
148
|
+
var toc = _toc;
|
149
|
+
var counter = 0;
|
150
|
+
var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
|
151
|
+
var i;
|
152
|
+
if ($('#filecontents h1').length > 1) tags.unshift('h1');
|
153
|
+
for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
|
154
|
+
var lastTag = parseInt(tags[0][1], 10);
|
155
|
+
$(tags.join(', ')).each(function() {
|
156
|
+
if ($(this).parents('.method_details .docstring').length != 0) return;
|
157
|
+
if (this.id == "filecontents") return;
|
158
|
+
show = true;
|
159
|
+
var thisTag = parseInt(this.tagName[1], 10);
|
160
|
+
if (this.id.length === 0) {
|
161
|
+
var proposedId = $(this).attr('toc-id');
|
162
|
+
if (typeof(proposedId) != "undefined") this.id = proposedId;
|
163
|
+
else {
|
164
|
+
var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
|
165
|
+
if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
|
166
|
+
this.id = proposedId;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
if (thisTag > lastTag) {
|
170
|
+
for (i = 0; i < thisTag - lastTag; i++) {
|
171
|
+
var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
if (thisTag < lastTag) {
|
175
|
+
for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
|
176
|
+
}
|
177
|
+
var title = $(this).attr('toc-title');
|
178
|
+
if (typeof(title) == "undefined") title = $(this).text();
|
179
|
+
toc.append('<li><a href="#' + this.id + '">' + title + '</a></li>');
|
180
|
+
lastTag = thisTag;
|
181
|
+
});
|
182
|
+
if (!show) return;
|
183
|
+
html = '<div id="toc"><p class="title"><a class="hide_toc" href="#"><strong>Table of Contents</strong></a> <small>(<a href="#" class="float_toc">left</a>)</small></p></div>';
|
184
|
+
$('#content').prepend(html);
|
185
|
+
$('#toc').append(_toc);
|
186
|
+
$('#toc .hide_toc').toggle(function() {
|
187
|
+
$('#toc .top').slideUp('fast');
|
188
|
+
$('#toc').toggleClass('hidden');
|
189
|
+
$('#toc .title small').toggle();
|
190
|
+
}, function() {
|
191
|
+
$('#toc .top').slideDown('fast');
|
192
|
+
$('#toc').toggleClass('hidden');
|
193
|
+
$('#toc .title small').toggle();
|
194
|
+
});
|
195
|
+
$('#toc .float_toc').toggle(function() {
|
196
|
+
$(this).text('float');
|
197
|
+
$('#toc').toggleClass('nofloat');
|
198
|
+
}, function() {
|
199
|
+
$(this).text('left');
|
200
|
+
$('#toc').toggleClass('nofloat');
|
201
|
+
});
|
202
|
+
}
|
203
|
+
|
204
|
+
$(framesInit);
|
205
|
+
$(createSourceLinks);
|
206
|
+
$(createDefineLinks);
|
207
|
+
$(createFullTreeLinks);
|
208
|
+
$(fixBoxInfoHeights);
|
209
|
+
$(searchFrameLinks);
|
210
|
+
$(linkSummaries);
|
211
|
+
$(keyboardShortcuts);
|
212
|
+
$(summaryToggle);
|
213
|
+
$(fixOutsideWorldLinks);
|
214
|
+
$(generateTOC);
|