farsi(persian) codepage for SheetJS #26

Open
opened 2021-05-08 19:52:41 +00:00 by arshi79 · 0 comments
arshi79 commented 2021-05-08 19:52:41 +00:00 (Migrated from github.com)

hi
I'm trying to convert an excel file(input type file) to html table. my code does work but it shows most of the letters in unreadable format because most of my excel cells are in farsi and farsi letters are special characters. I know that some arabic codepages cover farsi letters (such as 1256) but my code doesn't show letters correctly even after i use codepage
please help

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="jquery.min.js"></script>
    <script lang="javascript" src="xlsx.full.min.js"></script>
    <script src="JavaScript.js" type="text/javascript"></script>
    <script src="cpexcel.js"></script>
    <script src="cptable.js"></script>
    <script src="1256.js"></script>
    <meta charset="UTF-8" />
</head>
<body>
    <div id="navbar"><span>Red Stapler - SheetJS </span></div>
<div id="wrapper">
        <input type="file" id="input-excel" />
</div>
<script>
        $('#input-excel').change(function(e){
                var reader = new FileReader();
                reader.readAsArrayBuffer(e.target.files[0]);
                reader.onload = function(e) {
                    var data = new Uint8Array(reader.result);
                    var wb = XLSX.read(data, { type: 'array', codepage: 1256,charset:'UTF-8'});
                    var htmlstr = XLSX.write(wb, { sheetIndex:1 , type: 'binary', bookType: 'html',});
                        $('#wrapper')[0].innerHTML += htmlstr;
                }
        });
</script>
</body>
</html>
hi I'm trying to convert an excel file(input type file) to html table. my code does work but it shows most of the letters in unreadable format because most of my excel cells are in farsi and farsi letters are special characters. I know that some arabic codepages cover farsi letters (such as 1256) but my code doesn't show letters correctly even after i use codepage please help ``` <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="jquery.min.js"></script> <script lang="javascript" src="xlsx.full.min.js"></script> <script src="JavaScript.js" type="text/javascript"></script> <script src="cpexcel.js"></script> <script src="cptable.js"></script> <script src="1256.js"></script> <meta charset="UTF-8" /> </head> <body> <div id="navbar"><span>Red Stapler - SheetJS </span></div> <div id="wrapper"> <input type="file" id="input-excel" /> </div> <script> $('#input-excel').change(function(e){ var reader = new FileReader(); reader.readAsArrayBuffer(e.target.files[0]); reader.onload = function(e) { var data = new Uint8Array(reader.result); var wb = XLSX.read(data, { type: 'array', codepage: 1256,charset:'UTF-8'}); var htmlstr = XLSX.write(wb, { sheetIndex:1 , type: 'binary', bookType: 'html',}); $('#wrapper')[0].innerHTML += htmlstr; } }); </script> </body> </html> ```
Sign in to join this conversation.
No Milestone
No project
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/js-codepage#26
No description provided.