简体   繁体   English

Excel与宏

[英]Excel with Macro

Hai i want to download an excel sheet which contain Macro. Hai,我想下载一个包含Macro的Excel工作表。 But i use Php script to downlaod the excel. 但是我用PHP脚本贬低了Excel。 Is it Possible to download an excel sheet with macro in php? 是否可以在php中下载带有宏的Excel工作表?

Fetching Excel file with macro is really not different from fetching the one without one. 使用宏获取Excel文件实际上与不使用宏获取Excel文件没有什么不同。 You can use CURL for that. 您可以为此使用CURL。

<?php
$ch = curl_init("http://www.example.com/you_excel_sheet.xls");
$fp = fopen("local_excel_sheet.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);

The download code doesn't care what's inside the file. 下载代码不在乎文件中的内容。 There shouldn't be any difference between downloading an Excel with or without macros (or any other file for that matter). 下载带有或不带有宏(或与此相关的任何其他文件)的Excel之间应该没有任何区别。

Yes, it is possible. 对的,这是可能的。 Your code will work the same whether or not the excel file has macros in it. 无论excel文件中是否包含宏,您的代码都将起作用。 Just download the file, and then open it like normal, and the macros should work fine. 只需下载文件,然后像平常一样打开它,宏应该可以正常工作。

The only problem you might have is that you are trying to download an Excel 2007 file. 您可能遇到的唯一问题是,您正在尝试下载Excel 2007文件。 Normally, the file extension for an Excel 2007 file is .xlsx , but if you have macros in the file, then it will end with .xlsm . 通常,Excel 2007文件的文件扩展名是.xlsx ,但是如果文件中包含宏,则它将以.xlsm结尾。 Make sure that you are not trying to download the file with the wrong extension, and you should be fine. 确保您不尝试下载扩展名错误的文件,并且应该没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM