简体   繁体   中英

Excel with Macro

Hai i want to download an excel sheet which contain Macro. But i use Php script to downlaod the excel. Is it Possible to download an excel sheet with macro in php?

Fetching Excel file with macro is really not different from fetching the one without one. You can use CURL for that.

<?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).

Yes, it is possible. Your code will work the same whether or not the excel file has macros in it. 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. 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 . Make sure that you are not trying to download the file with the wrong extension, and you should be fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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