Home > OS >  How to open excel application by html or JavaScript
How to open excel application by html or JavaScript

Time:11-01

I want to open excel application by html or java script

I want to open excle file by html or javascript just call excel application

CodePudding user response:

this is a way do Display Office-Documents on a website: Embed Microsoft Documents in HTML Page

If you want to open the file in MS Office, if it’s installed, use a link element. At least Firefox you can automatically open filetypes with their corresponding applications. Specify the file with href="file:///name.docx" and choose "always open this filetype automatically".

This is also answered in this question.

CodePudding user response:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://unpkg.com/[email protected]/bundle/read-excel-file.min.js"></script>
    <title>Document</title>
</head>

<body>
    <input type="file" id="input" />
    <table id="tb1-data"></table>

    <script>
        var input = document.getElementById('input');
        input.addEventListener('change', function () {
            readXlsxFile(input.files[0]).then(function (data) {
                console.log("Excel file data :", data);
            });
        });
    </script>
</body>

</html>

To read or open excel file using javascript you need to add the cdn of a javascript library : <script src="https://unpkg.com/[email protected]/bundle/read-excel-file.min.js"></script>

With the program above you can log the xlsx file data to the console and read it by inspecting to the console

  • Related