forked from fg1998/bootstrapExcelExport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
253 lines (253 loc) · 12.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Export Table to Excel</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Bootstrap Export Table to Excel Plugin</h1>
</div>
<h3>What is this ?</h3>
<p>
This is a simple usage plugin to export HTML <code><table></code> to excel files. In fact, alow user to save html data to disk as a .xls file. It was developed with
<a href="http://getbootstrap.com/">Twitter Bootstrap</a> in mind, but you can use with regular html tables instead.
</p>
<p>It´s based on <a href="https://github.com/battatech/battatech_excelexport">Batta Tech Excel Export</a>, but a bit more simple.</p>
<p>You can try a demo <a href='http://www.cigi.com.br/bootstrapexcel/sample.html'>here</a></p>
<h3>How to use</h3>
<p>
First of all, you need a HTML <code><table></code> decorated or not with bootstrap css <code>table</code>, <code>table-striped</code>, etc.
Then, create a link using <code><a></code> tag. Again, you can decorate or not with bootstrap commom button
look and feel css for <code><a></code> links using <code>btn btn-default</code>. At last, Use the <code><a></code> selector to determine plugins behavior on button click.
</p>
<p>Let´s see some pieces of code...</p>
<h3>Code</h3>
<p>1.Include the plugin in your html. Of course, you <strong>must</strong> have jquery previously loaded - it´s a bootstrap plugin, remember ?</p>
<pre><script src='fg1998/jquery-bootstrapExportExcel.js'></script></pre>
<p>2.Create a table markup adding follow code like this :</p>
<pre>
<table class='table table-bordered' id='tblExample'>
<thead>
<tr>
<th>#</th>
<th>Column heading</th>
<th>Column heading</th>
<th>Column heading</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">4</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
</tbody>
</table>
</pre>
<p>3.Create a <code><a></code> link for click and save</p>
<pre>
<a id='btnExport' class='btn btn-primary'>Click me for save<a>
</pre>
<p>4.Use the <code><a></code> selector to connect with plugin. Don´t you forget to inform table id !</p>
<pre>
$('#btnExport').bootstrapExcelExport({ tableSelector : '#tblExample' });
</pre>
<h3>Example</h3>
<div class="row">
<div class="col-md-6">
<table class="table table-bordered" id='tblExample'>
<thead>
<tr>
<th>#</th>
<th>Column heading</th>
<th>Column heading</th>
<th>Column heading</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">4</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">5</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">6</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">7</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">8</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
<tr>
<th scope="row">9</th>
<td>Column content</td>
<td>Column content</td>
<td>Column content</td>
</tr>
</tbody>
</table>
<a id='btnExport' name="btnExport" class="btn btn-primary" download>Click me for save</a>
</div>
</div>
<h3>Options</h3>
<p>Attention - all options are in <a href='https://en.wikipedia.org/wiki/CamelCase'>lower camel case</a>.</p>
<div class="row">
<div class="col-md-12">
<table class="table-bordered table">
<thead>
<tr>
<th>Property</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tr>
<td>tableSelector</td>
<td>required</td>
<td>This is the table identifer. You can use any jQuery compliance selector</td>
</tr>
<tr>
<td>fileName</td>
<td>optional</td>
<td>Use this to change default name of downloade file. The default is <em>download.xls</em>. Dont forget to include the extension <mark>.xls</mark>.</td>
</tr>
<tr>
<td>worksheetName</td>
<td>optional</td>
<td>Change the excel worksheet name. Default is <em>My Worksheet</em></td>
</tr>
<tr>
<td>encoding</td>
<td>optional</td>
<td>Default is <em>utf-8</em>. Change to encoding you need if necessary</td>
</tr>
</table>
</div>
</div>
<h3>Useful links</h3>
<p><a href="http://getbootstrap.com/">Bootstrap</a> - The most popular HTML, CSS and JS Framework for developing responsive, mobile first projects on the web.</p>
<p><a href="http://jquery.com/">jQuery</a> - jQuery is a fast, small, and feature-rich JavaScript library.</p>
<p><a href="https://github.com/battatech/battatech_excelexport">Battatech excelexport</a> - Very useful and rick tool to export HTML tables to excel.</p>
<h3>Compatibility</h3>
<p>List of tested and compatibility browsers</p>
<div class="row">
<div class="col-md-12">
<table class="table-bordered table">
<thead>
<tr>
<th>Browser</th>
<th>Version tested</th>
<th>Compatibility</th>
</tr>
<tr>
<td>Chrome</td>
<td>40</td>
<td>Compatible</td>
</tr>
<tr>
<td>Firefox</td>
<td>34</td>
<td>Compatible</td>
</tr>
<tr>
<td>Opera</td>
<td>26</td>
<td>Compatible</td>
</tr>
<tr>
<td>Safari</td>
<td>5</td>
<td><strong>Not compatible</strong></td>
</tr>
<tr>
<td>Internet Explorer</td>
<td>11</td>
<td><strong>Not compatible</strong></td>
</tr>
</thead>
</table>
</div>
</div>
<h3>License</h3>
<p>Coded by <a href="https://www.facebook.com/fg1998">fg1998</a></p>
<p>
I really don´t know much about license. I believe the <em>Apache.org Version 2.0</em> is enough for everyone. In feel words, you can use, copy, modify, etc whatever you want. I hope this piece of software cand be useful for you.
If you need some more, please let me know.
</p>
<pre>http://www.apache.org/licenses/LICENSE-2.0</pre>
<p>I found this text and I believe it is important... </p>
<blockquote>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</blockquote>
</div>
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<!-- plugin -->
<script src="fg1998/jquery-bootstrapExportExcel.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
$('#btnExport').bootstrapExcelExport({ tableSelector: '#tblExample', worksheetName: 'foobar', fileName: "Excel_export.xls" });
});
</script>
</body>
</html>