Skip to content

farsi(persian) codepage for SheetJS #26

Description

@arshi79

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>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions