Ticker

6/recent/ticker-posts

vuejs export html to excel

export html to excel

import data from html to excel

html to excel converter free download

export html table to excel with formatting

html data to excel

export html form data to excel using javascript

copy html table to excel

html to excel php

export html table data to excel using jquery

A Pen by Edward Lance Lorilla on CodePen.

License.

<div id="app">
<button @click="tableToExcel('table', 'Lorem Table')">export </button>
<table ref="table" id="loremTable" summary="lorem ipsum sit amet" rules="groups" frame="hsides" border="2">
<caption>lorem ipsum</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
<colgroup span="2" align="center"></colgroup>
<colgroup span="3" align="center"></colgroup>
<thead valign="top">
<tr>
<th>id</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>lorem ipsum</td>
<td>sit amet</td>
</tr>
</tbody>
</table>
</div>
view raw index.html hosted with ❤ by GitHub
new Vue({
data(){
return{
uri :'data:application/vnd.ms-excel;base64,',
template:'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
base64: function(s){ return window.btoa(unescape(encodeURIComponent(s))) },
format: function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
}
},
methods:{
tableToExcel(table, name){
if (!table.nodeType) table = this.$refs.table
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
window.location.href = this.uri + this.base64(this.format(this.template, ctx))
}
}
}).$mount('#app')
view raw script.js hosted with ❤ by GitHub
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js"></script>
view raw scripts hosted with ❤ by GitHub

Post a Comment

2 Comments

nnameMR said…
can we create multiple worksheets by this method?
Anonymous said…
Edward Lance Lorilla >>>>> Download Now

>>>>> Download Full

Edward Lance Lorilla >>>>> Download LINK

>>>>> Download Now

Edward Lance Lorilla >>>>> Download Full

>>>>> Download LINK