Open adityos2003 opened 7 years ago
You can give those particular cells ID or class and can give CSS to change these.
- Neither is exporting other than with the export renderer: https://github.com/nicolaskruchten/pivottable/wiki/Frequently-Asked-Questions#exporting-renderer-output-to-excel-or-images
thanks before solution its, and then asking about export, if it can without copy image and than paste image in the excel ?. i mean have button and then click export to .xlsx (excel) or csv (save), like format pivot table and graph report in excel.
Like I said, there is no built-in way to export to Excel or CSV, sorry :)
oh ok nic, thanks, i'm fun learn nic, all code in web so may you help me, about above
thanks nic, sory about question me, because i'm excited learn code this. about last question cookie, first i think the pivot js can print/export excel then i need view pivot and then can to print/save/export in excel, the big deals i have idea to view in html pivot from render js and then -> it has button click to excel, so do you help me ? step and example return with picture, thanks nic
I'm sorry but I cannot understand what you're asking for :(
its ok, i mean like this in new box bold
I'm sorry but I cannot understand what you're asking for :(
OK, but as I told you above:
If you need to accomplish the goals above, you will have to write your own code for this, and I suggest you seek help on StackOverflow.
thanks nic, i will try code
hi nic i will try this code like this :
« back to PivotTable.js examples
the question
how i can export/download/save to excel in bold box from button Export to TAB (Excel) ? with sample source.
i'm compare the question like https://github.com/nicolaskruchten/pivottable/issues/639 , what is similiar? .
Thanks nic
You can use the css above to hide the total column and row, or you can add a bit of extra code to actually remove them. Using the onRefresh callback, just add an ID attribute to the pivot table (used for this purpose and later for export), and then remove the offending column and row.
$("#output").pivotUI(
$.pivotUtilities.myData, {
rows: ["row1", "row2", "row3", "row4",],
cols: ["col1", "col2"],
vals: ["values"],
aggregatorName: "List Unique Values",
rendererName: "Table",
onRefresh: function() {
$('table .pvtTable').attr('id', 'mytable');
$('#mytable thead tr:first').find('th:last').remove();
$('#mytable tr').find('td:last').remove();
$('#mytable').find('tr:last').remove();
}
});
To export to Excel, I experimented with several options and none seemed to work in all browsers or were able to handle the thousands of lines in my pivot tables. I finally found one a couple days ago called SheetJS. It even maintains most of the table formatting (colspans, etc.). After including the necessary js files:
<!-- SheetJS js-xlsx library -->
<script type="text/javascript" src="//unpkg.com/xlsx/dist/xlsx.full.min.js"></script>
<!-- FileSaver.js is the library of choice for Chrome -->
<script type="text/javascript" src="//rawgit.com/eligrey/Blob.js/master/Blob.js"></script>
<script type="text/javascript" src="//rawgit.com/eligrey/FileSaver.js/master/FileSaver.js"></script>
Then a bit of code:
function exportData(fn) {
return export_table_to_excel('mytable', 'xlsx', fn);
}
function s2ab(s) {
if(typeof ArrayBuffer !== 'undefined') {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
} else {
var buf = new Array(s.length);
for (var i=0; i!=s.length; ++i) buf[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
}
function export_table_to_excel(id, type, fn) {
var wb = XLSX.utils.table_to_book(document.getElementById(id), {sheet:"Sheet JS"});
var wbout = XLSX.write(wb, {bookType:type, bookSST:true, type: 'binary'});
var fname = fn || 'myFileName.' + type;
try {
saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), fname);
} catch(e) { if(typeof console != 'undefined') console.log(e, wbout); }
return wbout;
}
Then just trigger it with a exportData();
function call.
could you help me, complete code and then ready to run
there is no need for other JavaScript libraries
export: function () { var uri = 'data:application/vnd.ms-excel;base64,', template = '\
<!--[if gte mso 9]>
Hello mr nicholas , before thanks for opensource this source, because i can pivot in localhost so and then help me to remove total and freeze and button export to excel, thanks