Tom Cruise
Tom Cruise

Reputation: 1415

how to convert excel to html table in jquery?

I need to convert an excel that will be selected by the user there by display in a html table in the screen. Anyway to do this in client side using html or javascript/jquery/html5 without uploading to server?

I will get the file using an input file.

when the user clicks on upload the file data should be displayed on the html table in the same page.

I also tried the below code

  function test() {
        debugger
            var Excel;
            Excel = new ActiveXObject("Excel.Application");
            Excel.Visible = false;
            a = Excel.Workbooks.Open("C:/Book1.xls").ActiveSheet.Cells(l, i).Value;
            //Excel.Quit()
            return a;
        }

        //where l is number of rows and i are columns...
        var i = 1;
        var l = 1;
        do {
            a = test()
            document.write("value is " + a + "\t"); i++;
            if (a == "");
            {
                l++;
                i = 1;
                document.write("\n");
            }
        }
        while (a == "");

but getting error automation server cannot create object.

Upvotes: 2

Views: 11243

Answers (1)

suman j
suman j

Reputation: 6960

You can use http://oss.sheetjs.com/js-xls/ to utilize fileReader API to read xls/xlsx content as json and feed into required jquery table element.

Upvotes: 2

Related Questions