Can Base64 conversion be handled within the code? #23

Closed
opened 2013-04-16 18:56:41 +00:00 by SKALIDHASAN · 1 comment
SKALIDHASAN commented 2013-04-16 18:56:41 +00:00 (Migrated from github.com)

Thanks for the Update on IE10, One more suggestion is to handle the Base64 conversion with in the code. Currently you have given an option to paste the Base64 string, can this be dynamically generated via the code accessing the variable "f" in the below code snippet?

function b64it(xlsxFile) {

    var xlsx = XLSX.readFile(xlsxFile, {type: 'file'});//<--How the base64 conversion should be handled
    process_xlsx(xlsx);
}

function handleDrop(e) {
    e.stopPropagation();
    e.preventDefault();
    var files = e.dataTransfer.files;
    var i,f;
    for (i = 0, f = files[i]; i != files.length; ++i) {
    b64it(f);//<-- f represents one of the files in the List

    /*
        var reader = new FileReader();
        var name = f.name;
        reader.onload = function(e) {
            var data = e.target.result;
            //var xlsx = XLSX.read(data, {type: 'binary'});
            var arr = String.fromCharCode.apply(null, new Uint8Array(data));
            var xlsx = XLSX.read(btoa(arr), {type: 'base64'});
            process_xlsx(xlsx);
        };
        //reader.readAsBinaryString(f);
        reader.readAsArrayBuffer(f);
    */  

    }//for

}//handleDrop
Thanks for the Update on IE10, One more suggestion is to handle the Base64 conversion with in the code. Currently you have given an option to paste the Base64 string, can this be dynamically generated via the code accessing the variable "f" in the below code snippet? ``` function b64it(xlsxFile) { var xlsx = XLSX.readFile(xlsxFile, {type: 'file'});//<--How the base64 conversion should be handled process_xlsx(xlsx); } function handleDrop(e) { e.stopPropagation(); e.preventDefault(); var files = e.dataTransfer.files; var i,f; for (i = 0, f = files[i]; i != files.length; ++i) { b64it(f);//<-- f represents one of the files in the List /* var reader = new FileReader(); var name = f.name; reader.onload = function(e) { var data = e.target.result; //var xlsx = XLSX.read(data, {type: 'binary'}); var arr = String.fromCharCode.apply(null, new Uint8Array(data)); var xlsx = XLSX.read(btoa(arr), {type: 'base64'}); process_xlsx(xlsx); }; //reader.readAsBinaryString(f); reader.readAsArrayBuffer(f); */ }//for }//handleDrop ```
Niggler commented 2013-04-16 19:17:18 +00:00 (Migrated from github.com)

I was originally working with IE6, which doesn't (as far as I can tell) support base64. The base64 mode was separated so that I could paste content into the textarea and test those features.

If you suggest a good way to add drag and drop support in IE6-9 (even if it required some flash or silverlight magic) I would get rid of the text box in a heartbeat.

To clarify: the base64 part is actually integrated in the zip container handling (the jszip.js file).

I was originally working with IE6, which doesn't (as far as I can tell) support base64. The base64 mode was separated so that I could paste content into the textarea and test those features. If you suggest a good way to add drag and drop support in IE6-9 (even if it required some flash or silverlight magic) I would get rid of the text box in a heartbeat. To clarify: the base64 part is actually integrated in the zip container handling (the jszip.js file).
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#23
No description provided.