Is it possible to call Excel and a macro from PHP?

I have a project where I am trying to connect a website with Microsoft Excel to run a quick function (a macro I’ve created). The macro and excel are on the server, not the client side. Is it possible to open Excel using PHP and call the macro? The Macro imports a text file (that was created by the PHP before the call) to do a quick calculation, and will save the output in a separate text file. The macro is being used because it utilizes a neural network add-in for Excel.

If this is not possible, is it possible to call and automatically start a program that accepts a text file and outputs a text file? (I am trying to run a neural network).

Your help is appreciated. Thanks!

Well, not the way you are thinking to do it. First, PHP is server-side only. It will not access any local machines to run ANY app’s programs. There is a way to read and write Excel files directly using PHP. This, of course, is done server-side, so the Excel file must be on the server.

You could create a local-machine service that runs on a local machine and call it from a connection using PHP.
In this manner, you would be able to send data back and forth, but, that is a very very hard thing to accomplish due to timing issues and connection issues. (Firewalls, antivirus and other issues…)

So, let’s go back to the original idea… You have some sort of Excel sheet. You created a macro to handle some of the data on the sheet. You want a webpage that executes the macro. First, why would a webpage want to call a spreadsheet? It would be much much better to keep your data in a MySql database and rewrite the macro in PHP. Then, set the macro to be a PHP global function and just call it when needed.

If you are talking about a user entering data into a spreadsheet, it could be uploaded to the server and then the PHP version of the macro could read the data from it and manipulate the data as needed.

Give us a few further ideas on why you want Excel to be involved on a webpage…

Oh, also, there are thousands of PHP neural net’s available for free online… A quick google search using
php free neural network library Found a bunch of free one…

Sponsor our Newsletter | Privacy Policy | Terms of Service