|
100 | 100 | } |
101 | 101 | return new Array(total).concat($(val).text()); |
102 | 102 | } |
103 | | - return $(val).text(); |
| 103 | + return formatValue($(val).text()); |
104 | 104 | }).get()]; |
105 | 105 | }).get(), |
106 | 106 | dataObject = TableExport.prototype.escapeHtml( |
|
151 | 151 | } |
152 | 152 | return new Array(total).concat($(val).text()); |
153 | 153 | } |
154 | | - return $(val).text(); |
| 154 | + return formatValue($(val).text()); |
155 | 155 | }).get()]; |
156 | 156 | }).get(), |
157 | 157 | dataObject = TableExport.prototype.escapeHtml( |
|
179 | 179 | if ($(val).is(emptyCSS)) { |
180 | 180 | return " " |
181 | 181 | } |
182 | | - return $(val).text(); |
| 182 | + return formatValue($(val).text()); |
183 | 183 | }).get().join(colD); |
184 | 184 | }).get().join(rdel), |
185 | 185 | dataObject = TableExport.prototype.escapeHtml( |
|
207 | 207 | if ($(val).is(emptyCSS)) { |
208 | 208 | return " " |
209 | 209 | } |
210 | | - return '"' + $(val).text().replace(/"/g, '""') + '"'; |
| 210 | + return '"' + formatValue($(val).text().replace(/"/g, '""')) + '"'; |
211 | 211 | }).get().join(colD); |
212 | 212 | }).get().join(rdel), |
213 | 213 | dataObject = TableExport.prototype.escapeHtml( |
|
235 | 235 | if ($(val).is(emptyCSS)) { |
236 | 236 | return " " |
237 | 237 | } |
238 | | - return $(val).text(); |
| 238 | + return formatValue($(val).text()); |
239 | 239 | }).get().join(colD); |
240 | 240 | }).get().join(rdel), |
241 | 241 | dataObject = TableExport.prototype.escapeHtml( |
|
259 | 259 | } |
260 | 260 | ); |
261 | 261 |
|
| 262 | + function trimWhitespace(string) { |
| 263 | + if (self.settings.trimWhitespace) { |
| 264 | + return $.trim(string); |
| 265 | + } |
| 266 | + return string; |
| 267 | + } |
| 268 | + |
| 269 | + function formatValue(string) { |
| 270 | + string = trimWhitespace(string); |
| 271 | + return string; |
| 272 | + } |
| 273 | + |
262 | 274 | function checkCaption(exportButton) { |
263 | 275 | var $caption = $el.find('caption:not(.head)'); |
264 | 276 | $caption.length ? $caption.append(exportButton) : $el.prepend('<caption class="' + bootstrapSpacing + self.settings.position + '">' + exportButton + '</caption>'); |
|
305 | 317 | ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file (default: null) |
306 | 318 | ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file (default: null) |
307 | 319 | ignoreCSS: ".tableexport-ignore", // (selector, selector[]), selector(s) to exclude cells from the exported file (default: ".tableexport-ignore") |
308 | | - emptyCSS: ".tableexport-empty" // (selector, selector[]), selector(s) to replace cells with an empty string in the exported file (default: ".tableexport-empty") |
| 320 | + emptyCSS: ".tableexport-empty", // (selector, selector[]), selector(s) to replace cells with an empty string in the exported file (default: ".tableexport-empty") |
| 321 | + trimWhitespace: false // (Boolean), remove all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of cell text |
309 | 322 | }, |
310 | 323 | /** |
311 | 324 | * Character set (character encoding) of the HTML. |
|
0 commit comments