Skip to content
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

Convert the base64 encoded data to a Blob to allow for exports of larger tables #48

Closed
wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 22, 2016

The problem

The current implementation encodes the tables in base64 and creates a download href. But this approach has a limit on how large can the base64 data be for the browser to be able to download/create the file.

Where it failed

I had trouble exporting >10000 rows with 2 columns only

The solution

A Blob object is created from the base64 encoded data, and a the anchor href is just a reference to that blob object. The explanation is taken from a stack overflow comment

Blagoj Atanasovski added 3 commits August 22, 2016 13:07
@craignicol
Copy link

I had a similar solution in #44 but this looks slightly more robust.

@craignicol
Copy link

How about adding the msSaveBlob to add IE support, now you've got the heavy lifting to use blobs

@ghost
Copy link
Author

ghost commented Aug 22, 2016

Thanks for the comment, I just saw your code, I'll try to combine it with these changes, but i'll have to set up my windows env first 😄 i'm running linux currently

As seen in the pull request #44 or user @craignicol
@craignicol
Copy link

craignicol commented Aug 24, 2016

Just tested it myself, works on Chrome, IE and Edge, but not Firefox gives me TypeError: Argument 2 of URL.createObjectURL can't be converted to a dictionary. at excellentexport.js:178:27

I used { type: 'application/vnd.ms-excel'} as the type to support both Chrome and Firefox (and an equivalent dictionary for csv)

@@ -167,18 +168,32 @@ ExcellentExport = (function() {
return data;
};

function createDownloadLink(anchor, base64data, exporttype, filename){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firefox requires the export type to be of the format "{type: exporttype}"

jmaister added a commit that referenced this pull request Sep 19, 2016
@jmaister
Copy link
Owner

Merged the pull request. Thanks @atanasovskib !!

It had some conflicts but works great.

@jmaister jmaister closed this Sep 19, 2016
@jmaister jmaister mentioned this pull request Sep 19, 2016
@jmaister jmaister mentioned this pull request Oct 3, 2016
@gspringtech
Copy link

gspringtech commented Oct 25, 2016

The Firefox error persists in the 2.0.0 version (downloaded today) for Firefox 49.0.1 when using the CSV export.
A temporary fix involves replacing "exporttype" on line 105 with
{ type : exporttype}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants