Read Excel data with JQuery

前端 未结 5 1929
温柔的废话
温柔的废话 2020-12-13 20:28

I would like to know how to read data from a multi-worksheet MS Excel 2003 file using nothing, but jquery. I have read several solutions for PHP/JQuery, ActiveX, etc..., but

相关标签:
5条回答
  • 2020-12-13 21:14

    Convert the excel in a CSV file to get read from Jquery. make use of the Jquery plugin CSV2Table

    <div id="view1"></div>
    <script type="text/javascript">
    $(function(){
        $('#view1').csv2table('Path/Anil.csv');
    });
    </script>
    
    0 讨论(0)
  • 2020-12-13 21:15

    Actually it's possible without OWC and such exotic addins, but manual work will be required. Another thing - it's doable on local machine only - don't expect your worksheet to act like a web server. Another possibility is to set it up on a network share, but I'm not sure how will it all work in the sandbox.

    EDIT: I know the question was about Excel 2003 format. However, there are still Google queries about the same functionality and today people are using MS Office versions 2010/2013. So, I believe the answer can be beneficial to the reader.

    So, here it is:

    1. Using zip.js you can open zipped files. This means you can open MS Office files starting from Office 2007 (.docx, .xlsx. etc). Older office files have custom format and you can't read them as zipped files.
    2. After you open the file, hierarchical folder structure with various files in it is available. The data itself is in /xl/worksheets/[worksheet name].xml and /xl/sharedStrings.xml, which means you have to dig it out using XML parser and correlate afterwards.
    3. Luckily enough, XML parser is available in jQuery: $.parseXML('...')

    Have fun ;)

    0 讨论(0)
  • 2020-12-13 21:19

    There are a few tools (libraries) for nodeJS that you can find on the npm website. There's one called excel that reads xlsx files and there's one called office for most ms office files. Now since it's all Javascript anyway, you should be able to download, and check out the source to find a way to integrate it on the client-side. Hope that helps

    0 讨论(0)
  • 2020-12-13 21:30

    Office Web Components provide an api to excel documents via javascript (or vb). They are poorly documented but for intranet type applications they can get the job done. I have used them for the pivot table functionality in IE6 and do not know if it will work with Firefox.

    http://en.wikipedia.org/wiki/Office_Web_Components

    http://www.microsoft.com/downloads/en/details.aspx?FamilyID=beb5d477-2100-4586-a13c-50e56f101720&DisplayLang=en

    0 讨论(0)
  • 2020-12-13 21:32

    I realize this question is old, but I have a basic parser that supports most of what you are asking for: http://oss.sheetjs.com/js-xls/

    0 讨论(0)
提交回复
热议问题