In a calculation provided by my Windows server, I have to make Microsoft Excel involve because of technology limitations: I need to systematically open Excel inside the server, read content of an Excel file to generate a txt file, and then close the Excel.
To this end, I have installed Microsoft Office 2016
in the virtual machine of Microsoft Server 2012 R2
. I host a webpage http://test.addbba.com/batch.html
in the server: clicking on the button leads to running batch.php
:
(* batch.php: *)
<?php
echo "Hello world!";
system("cmd /c C:/inetpub/testaddbbacom/generateFile.bat");
// system("cmd /c C:/inetpub/testaddbbacom/openExcel.bat");
echo "Bye world!";
?>
(* generateFile.bat: *)
echo "abc" > haha.txt
(* openExcel.bat: *)
"C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"
Double-clicking generateFile.bat
and openExcel.bat
in windows server in Microsoft Remote Desktop
works well; openExcel.bat
does open Excel which works like on-premise.
By batch.php
, system("cmd /c C:/inetpub/testaddbbacom/generateFile.bat");
works too. However, the problem is about system("cmd /c C:/inetpub/testaddbbacom/openExcel.bat");
: after uncommenting that line, and clicking on the button, I don't see Excel launching in Microsoft Remote Desktop
, and I don't know if anything is happening behind the screen.
To conclude, I have to use (i.e., open, close) Excel itself as a step of my automatisation in Windows server. Automating this in a windows desktop is easy, whereas how could I make it work in a Windows server?
Could anyone help?