SheetJS / js-codepage

:currency_exchange: Codepages for JS
http://sheetjs.com
Apache License 2.0
151 stars 39 forks source link

farsi(persian) codepage for SheetJS #26

Open arshi79 opened 3 years ago

arshi79 commented 3 years ago

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>