New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to export datatable with huge rows to excel file ? #70
Comments
I can't reproduce your problem. Here is a working example for a table with 3288+1 ;) rows: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML table Export</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="../libs/FileSaver/FileSaver.min.js"></script>
<script type="text/javascript" src="../tableExport.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var Table = document.getElementById ( 'container' );
var T = [];
var r = 0;
var rmax = 3289;
T.push('<table id="grid">');
T.push('<thead>');
T.push('<tr>');
T.push('<th>col 1</th>');
T.push('<th>col 2</th>');
T.push('<th>col 3</th>');
T.push('<th>col 4</th>');
T.push('</tr>');
T.push('</thead>');
T.push('<tbody>');
while (r++ < rmax) {
T.push('<tr>');
T.push('<td>' + r + '</td>');
T.push('<td>' + getRandomInt(100,10000) + '</td>');
T.push('<td>' + getRandomInt(100,10000) + '</td>');
T.push('<td>' + getRandomInt(100,10000) + '</td>');
T.push('</tr>');
}
T.push('</tbody>');
T.push('</table>');
Table.innerHTML = T.join ("");
$('#export').click(function() {
$('#grid').tableExport({type:'excel'});
});
});
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
</script>
</head>
<body>
<button id="export">Export to Excel</button>
<div id="container">
</div>
</body>
</html> Are you using my fork of the plugin? I'm asking this, because you also opened the same issue here, which differs a lot from my version. |
Sorry, |
That "3288+1" thing was just ironic. And yes my tableExport.js works with that amount of rows (and more) as the example above shows. You didn't tell anything about the content of your table. Without more details I only can speculate on the reasons for your problem. |
I think i found the reason, maybe it because of Chrome, cause when i use Firefox it can export nomarlly. Maybe cause Chrome limited file size or something...Can't sure |
I'd like to way in here. Chrome and Safari BOTH have an issue when exporting > 2.5 mb excel files. In my example: |
Based on Off this forum: astrojs/fitsjs#13 PS: Exl file in Other browsers fixed and corrected once I Used FileSaver plugin. ~"noob" |
Hi, first thank you for digging into this! The stackoverflow links gave me a hint why I didn't watch that problem. My mass data tests with chrome and firefox produced complete xls files larger than 2.5 mb. As you noticed in your last comment "Blob" is the solution. |
@hhurz - Thanks for responding! So as you stated - the Filesaver.js does work! However - unfortunately Safari 5.1.7 which is the latest Window release (deprecated now) will never work with BLOB. BLOB's exists but the BLOB constructor does not. I wasn't able to test in Safari > 5.1.7. And none of my findings have gotten 5.1.7 Safari to work otherwise (may be completely unsupportable) Hope this info helps! |
That might sound a bit arrogant, but I don't intend to support Safari for Windows. The browser support is limited to those mentioned in the readme of Filesaver.js |
@hhurz I have noticed the same problem on Google Chrome, the issue seems to be related with the amount of data that is being exported and not the amount of rows. For example, I can export 1744 rows with a few columns in nearly no time (i.e. less than 10 seconds with the file size being a bit more than 1 Mb), then if I add an additional column that is containing lots of anchors, then the export takes much longer (i.e. more than 5 minutes) and at the end it just opens a new blank window instead of downloading the new file. Edit : After further investigation, I think that this bit of code is limited to the browser maximum URL's length
I haven't tested but something like this could probably solve the issue although I am not sure that the base64 encoding would still be needed in that case.
|
@ggobbe Thanks for digging into this. I'm confused a bit, but neither tabelExport.js nor FileSaver.js use |
@hhurz Sorry I didn't notice but the project I have been debugging, that I didn't wrote, is using bootstrap-table which is using some sort of version of your library. After further investigation it turns out that it is in the bootstrap-table-export.js exportTable function that this code is whereas you are using Blob and saveAs() to save the file. Sorry for the confusion and thanks for your help I'll go raise an issue on that project. |
@hhurz I found the *.csv code is ANSI, but i can tranform it to utf8, do you having another method? |
Dear,
I have a dataTable with 3288 rows, the export to excel is ok with dataTable arround 1000 rows but when the number of rows too many, it can't export to excel.
Please help me is there anyway to fix it?
Thank you.
The text was updated successfully, but these errors were encountered: