当从我的网页上下载电子表格(.xls)时,如何在MS Excel 07电子表格中显示计数器(即,下载的次数)?

时间:2021-09-13 11:17:29

I know it is easy to display a counter on a webpage but I need to implement the same, ie, I need to write data to a cell in the Excel 2007 spreadsheet every time a person downloads it from my webpage. To be more precise, when the user downloads the excel file to his hard drive and when it is opened, I want the spreadsheet to display the number of times the .xls file has been downloaded, in a cell (ofcourse along with other cells containing data).

我知道在网页上显示计数器很容易,但我需要实现相同的,即每次有人从我的网页下载数据时,我需要将数据写入Excel 2007电子表格中的单元格。更准确地说,当用户将excel文件下载到他的硬盘驱动器并且打开它时,我希望电子表格显示.xls文件已被下载的次数,在一个单元格中(当然包含其他单元格)数据)。

I just need to figure out how do i programmmatically communicate with Excel 07 sheet.

我只需要弄清楚如何与Excel 07表格进行程序化通信。

1 个解决方案

#1


That sounds like an exercise in futility since the number will be out of date as soon as the next person downloads the file. Is this what you really want to do?

这听起来像是一种无用的练习,因为一旦下一个人下载文件,该数字就会过时。这是你真正想做的吗?

If yes, it's very possible using some server-side scripts. PHP, Perl and other languages all have libraries that can be used to edit Excel files programmatically. Pick the one you are most comfortable with and go from there.

如果是,使用一些服务器端脚本很可能。 PHP,Perl和其他语言都有可用于以编程方式编辑Excel文件的库。选择一个你最舒服的那个并从那里开始。

EDIT:

I think the best way to go since you control both the Excel file and the website is to add a counter to the website, and reference it in your Excel file via web queries. If you're not familiar with web queries, they are a tool in excel that let you import tables from the web that will be refreshed everytime the file loads (or even if a user hits refresh). Here's more information about the Web Query Tool.

我认为,既然您控制Excel文件和网站,最好的方法是在网站上添加一个计数器,并通过Web查询在Excel文件中引用它。如果您不熟悉Web查询,它们是excel中的一个工具,可以让您从Web导入每次加载文件时刷新的表(或者即使用户点击刷新)。以下是有关Web查询工具的更多信息。

Let me know if this solution works for you.

如果此解决方案适合您,请告诉我。

EDIT2:

Here's a link to a more up-to-date tutorial.

这是一个更新的教程链接。

#1


That sounds like an exercise in futility since the number will be out of date as soon as the next person downloads the file. Is this what you really want to do?

这听起来像是一种无用的练习,因为一旦下一个人下载文件,该数字就会过时。这是你真正想做的吗?

If yes, it's very possible using some server-side scripts. PHP, Perl and other languages all have libraries that can be used to edit Excel files programmatically. Pick the one you are most comfortable with and go from there.

如果是,使用一些服务器端脚本很可能。 PHP,Perl和其他语言都有可用于以编程方式编辑Excel文件的库。选择一个你最舒服的那个并从那里开始。

EDIT:

I think the best way to go since you control both the Excel file and the website is to add a counter to the website, and reference it in your Excel file via web queries. If you're not familiar with web queries, they are a tool in excel that let you import tables from the web that will be refreshed everytime the file loads (or even if a user hits refresh). Here's more information about the Web Query Tool.

我认为,既然您控制Excel文件和网站,最好的方法是在网站上添加一个计数器,并通过Web查询在Excel文件中引用它。如果您不熟悉Web查询,它们是excel中的一个工具,可以让您从Web导入每次加载文件时刷新的表(或者即使用户点击刷新)。以下是有关Web查询工具的更多信息。

Let me know if this solution works for you.

如果此解决方案适合您,请告诉我。

EDIT2:

Here's a link to a more up-to-date tutorial.

这是一个更新的教程链接。