javascript 如何在 html 中嵌入实时 Excel 电子表格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6895435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to embed a live excel spreadsheet in html
提问by hsjbrk
hi i would like to know how i can embed a excel spreadsheet in a web page and change the excel numbers on the hosted file and this in turn automatically changes the webpage sheet?
嗨,我想知道如何在网页中嵌入 excel 电子表格并更改托管文件上的 excel 编号,从而自动更改网页表?
would like to know if there is a jquery, javascript, css etc code to help me out
想知道是否有 jquery、javascript、css 等代码来帮助我
for example, book1.xls will be uploaded to the server and index.html will reflect book1.xls as a table in it. when i update book1.xls, it should automatically show in index.html the changed cells.
例如,book1.xls 将被上传到服务器,而 index.html 将把 book1.xls 反映为其中的一个表。当我更新 book1.xls 时,它应该会自动在 index.html 中显示更改的单元格。
thanks in advance
提前致谢
回答by RolanDecoy
The simple way to actually connect to an XLS is through VBScript, but your server will have to support it (which most do).
实际连接到 XLS 的简单方法是通过 VBScript,但您的服务器必须支持它(大多数都支持)。
Another way would be add an ODBC to your servers connectors pointing to your XLS or MDB or whatever Microsoft data file you choose and use JavaScript or any number of languages to connect to it, retrieve data, make changes, etc. The downside is that you must have Administrative rights to the computer hosting the file. You can use a homecomputer to use as server for that file only for instance and link it to your website, but it will affect loading speeds. This will however require you to take a closer look at your home internet security...!!!...but will enable you to make 'live' changes without going to your website. This method is often used for webshops and online catalogues, places where data can change on a daily basis but a database server is undesirable.
另一种方法是将 ODBC 添加到您的服务器连接器,指向您的 XLS 或 MDB 或您选择的任何 Microsoft 数据文件,并使用 JavaScript 或任何数量的语言连接到它,检索数据,进行更改等。缺点是您必须对托管文件的计算机具有管理权限。例如,您可以使用家用计算机作为该文件的服务器并将其链接到您的网站,但这会影响加载速度。然而,这将要求您仔细检查您的家庭互联网安全......!!!......但将使您能够在不访问您的网站的情况下进行“实时”更改。这种方法通常用于网上商店和在线目录,这些地方的数据每天都在变化,但不需要数据库服务器。
The simplest and easiest way is as mentioned before the use of GoogleDocs, but that will require conversion of the document. You won't be using your XLS as datafile. The downside here is that if you make any changes offline (not through the website) the changes will also not be visible, because you'll be editing a completely different file. So you'll need to convert and upload it to GoogleDocs each and every time.
最简单和最简单的方法是在使用 GoogleDocs 之前提到的,但这需要转换文档。您不会将 XLS 用作数据文件。这里的缺点是,如果您离线(不是通过网站)进行任何更改,这些更改也将不可见,因为您将编辑一个完全不同的文件。因此,您每次都需要将其转换并上传到 GoogleDocs。
As you can see the method used greatly depends on how often you plan on updating the data, how much traffic you expect and how secure you want it to be.
如您所见,所使用的方法在很大程度上取决于您计划更新数据的频率、您期望的流量以及您希望数据的安全性。
回答by Tom
A "live" spreadsheet can be shown in a web page via an iframe containing a Google Doc spreadsheet. You cut 'n paste the iframe markup from Google Docs and drop it into your web page. The spreadsheet is editable in GDocs. The iframe view can be set to automatically update when the ss is edited.
“实时”电子表格可以通过包含 Google Doc 电子表格的 iframe 显示在网页中。您从 Google Docs 剪切和粘贴 iframe 标记并将其放入您的网页中。电子表格可在 GDocs 中编辑。iframe 视图可以设置为在编辑 ss 时自动更新。
Perhaps, this is too bland a solution. But it works. I use it all the time.
也许,这是一个过于乏味的解决方案。但它有效。我用它所有的时间。
回答by g_thom
I doubt you can do that directly from an .xls file, but if you save your Excel file as .csv, you can read a .csv file via jQuery.
我怀疑您是否可以直接从 .xls 文件中执行此操作,但是如果您将 Excel 文件另存为 .csv,则可以通过 jQuery 读取 .csv 文件。
There's a plugin here that displays data from a csv file as a table: http://plugins.jquery.com/project/csv2table
这里有一个插件可以将 csv 文件中的数据显示为表格:http: //plugins.jquery.com/project/csv2table
The same/similar question is also asked in these posts:
这些帖子中也提出了相同/类似的问题: