we are having issues saving excel sheets in PHP.
Minimalistic code:
// R: is a Ramdisk
$filename = 'R:\\sheets\\ExcelFile_123.xlsx';
$application = new COM("Excel.Application", null, CP_UTF8);
$workbook = $application->Workbooks->Open($filename);
$workbook->save();
The call to save will throw a com_exception with message "Source: Microsoft Excel Description: Das Dokument wurde nicht gespeichert." (German for "The document was not saved.")
When any worksheet of the workbook has been opened and i am trying to save the worksheet again i get another com_exception with message "Source: Microsoft Excel Description: Zugriff auf 'ExcelFile_123.xlsx' verweigert." (German for "Access to 'ExcelFile_123.xlsx' denied.")
I checked following things:
I toggled every setting of the ones mentioned above and even tried https://support.microsoft.com/en-us/help/2589410/access-denied-error-message-when-you-save-a-workbook-to-a-unc-share-in
Solutions that are not suitable:
Question: Why can't i save the excel file, even though i have write access?
System information
PHP com_dotnet extension:
com_dotnet\
COM support enabled\
DCOM support disabled\
.Net support enabled\
Directive Local Value Master Value\
com.allow_dcom 0 0\
com.autoregister_casesensitive 1 1\
com.autoregister_typelib 0 0\
com.autoregister_verbose 0 0\
com.code_page no value no value\
com.typelib_file no value no value
It can be an issue with user profile under which your PHP application is running. Please check article on server-side office automation of office products (it has common problems listed). To see if the problem is actually the account, I would try to change the account under Apache (PHP) is running to your account (or simply start Apache command line to see if it fixes the problem).
https://support.microsoft.com/en-us/help/257757/considerations-for-server-side-automation-of-office
https://theether.net/download/Microsoft/kb/288367.html
BTW, there are (paid) alternatives as well that can do calculations and run server-side.