Skip to content
Extraits de code Groupes Projets
Valider 83b581de rédigé par Benjamin's avatar Benjamin
Parcourir les fichiers

[add] export to xlsx

parent cb7063b2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -36,3 +36,10 @@ ...@@ -36,3 +36,10 @@
.tresorerie .card-number { font-size: 20px; font-weight: 300; } .tresorerie .card-number { font-size: 20px; font-weight: 300; }
.ca_target:hover { cursor: pointer; color: rgba(115, 135, 156,0.5); } .ca_target:hover { cursor: pointer; color: rgba(115, 135, 156,0.5); }
.btn-tdb {
border: 1px solid #eee;
border-radius: 0;
font-size: 11px;
padding: 6px 10px;
text-transform: none;
}
\ No newline at end of file
...@@ -13,6 +13,10 @@ odoo.define('lefilament_tdb.dashboard', function(require) { ...@@ -13,6 +13,10 @@ odoo.define('lefilament_tdb.dashboard', function(require) {
var LeFilamentDashboard = Widget.extend({ var LeFilamentDashboard = Widget.extend({
template: 'Dashboard', template: 'Dashboard',
events: {
'click #export_excel': 'export_excel',
},
init: function() { init: function() {
var result = this._super.apply(this, arguments); var result = this._super.apply(this, arguments);
return result; return result;
...@@ -37,6 +41,26 @@ odoo.define('lefilament_tdb.dashboard', function(require) { ...@@ -37,6 +41,26 @@ odoo.define('lefilament_tdb.dashboard', function(require) {
}, },
export_excel: function(e) {
var table = TableExport(this.$el.find('#dataTable'), {
headers: true,
footers: false,
formats: ['xlsx',],
filename: 'Tableau de Bord', // (id, String), filename for the downloaded file, (default: 'id')
bootstrap: true, // (Boolean), style buttons using bootstrap, (default: true)
exportButtons: false, // (Boolean), automatically generate the built-in export buttons for each of the specified formats (default: true)
position: 'bottom', // (top, bottom), position of the caption element relative to table, (default: 'bottom')
ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file(s) (default: null)
ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file(s) (default: null)
trimWhitespace: true // (Boolean), remove all leading/trailing newlines, spaces, and tabs from cell text in the exported file(s) (default: false)
});
var exportData = table.getExportData();
console.log(exportData);
table.export2file(exportData.dataTable.xlsx.data, exportData.dataTable.xlsx.mimeType, exportData.dataTable.xlsx.filename, exportData.dataTable.xlsx.fileExtension);
},
render_monetary: function(value) { render_monetary: function(value) {
value = value.toLocaleString('fr', { maximumFractionDigits: 0 }) + ''; value = value.toLocaleString('fr', { maximumFractionDigits: 0 }) + '';
return value; return value;
......
/*! FileSaver.js v1.3.6
*
* A saveAs() FileSaver implementation.
*
* By Travis Clarke, https://travismclarke.com
* By Eli Grey, http://eligrey.com
*
* License: MIT (https://github.com/clarketm/FileSaver.js/blob/master/LICENSE.md)
*/
(function(e,t){if(typeof exports==="object"&&typeof exports.nodeName!=="string"){module.exports=e.document?t(e,true):function(e){if(!e.document){throw new Error("FileSaver requires a window with a document")}return t(e)}}else{t(e)}})(window||this,function(e,t){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var n=e.document,r=function(){return e.URL||e.webkitURL||e},o=n.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in o,a=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},f=/constructor/i.test(e.HTMLElement)||e.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent),c=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},d="application/octet-stream",s=1e3*40,l=function(e){var t=function(){if(typeof e==="string"){r().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,s)},p=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(e){c(e)}}}},w=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},m=function(t,n,c){if(!c){t=w(t)}var s=this,m=t.type,v=m===d,y,h=function(){p(s,"writestart progress write writeend".split(" "))},S=function(){if((u||v&&f)&&e.FileReader){var n=new FileReader;n.onloadend=function(){var t=u?n.result:n.result.replace(/^data:[^;]*;/,"data:attachment/file;");var r=e.open(t,"_blank");if(!r)e.location.href=t;t=undefined;s.readyState=s.DONE;h()};n.readAsDataURL(t);s.readyState=s.INIT;return}if(!y){y=r().createObjectURL(t)}if(v){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}s.readyState=s.DONE;h();l(y)};s.readyState=s.INIT;if(i){y=r().createObjectURL(t);setTimeout(function(){o.href=y;o.download=n;a(o);h();l(y);s.readyState=s.DONE});return}S()},v=m.prototype,y=function(e,t,n){return new m(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){y=function(e,t,n){t=t||e.name||"download";if(!n){e=w(e)}return navigator.msSaveOrOpenBlob(e,t)}}v.abort=function(){};v.readyState=v.INIT=0;v.WRITING=1;v.DONE=2;v.error=v.onwritestart=v.onprogress=v.onwrite=v.onabort=v.onerror=v.onwriteend=null;if(typeof define==="function"&&define.amd){define("file-saverjs",[],function(){return y})}if(typeof t==="undefined"){e.saveAs=y}return y});
\ No newline at end of file
Ce diff est replié.
Ce diff est replié.
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<p><button class="btn btn-default btn-tdb" id="export_excel">Export xslx</button></p>
</div> </div>
</t> </t>
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
<link href="/lefilament_tdb/static/src/css/lefilament_tdb.css" rel="stylesheet" /> <link href="/lefilament_tdb/static/src/css/lefilament_tdb.css" rel="stylesheet" />
<script type="text/javascript" src="/lefilament_tdb/static/src/lib/xlsx.core.min.js"></script>
<script type="text/javascript" src="/lefilament_tdb/static/src/lib/FileSaver.min.js"></script>
<script type="text/javascript" src="/lefilament_tdb/static/src/lib/tableexport.js"></script>
<script type="text/javascript" src="/lefilament_tdb/static/src/lib/progressBar.js"></script> <script type="text/javascript" src="/lefilament_tdb/static/src/lib/progressBar.js"></script>
<script type="text/javascript" src="/lefilament_tdb/static/src/js/lefilament_tdb.js"></script> <script type="text/javascript" src="/lefilament_tdb/static/src/js/lefilament_tdb.js"></script>
<script type="text/javascript" src="/lefilament_tdb/static/src/js/dashboard_year.js"></script> <script type="text/javascript" src="/lefilament_tdb/static/src/js/dashboard_year.js"></script>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter