This answer comes as an answer of your comment.
Take a look at these links:
Accessing Excel Spreadsheets via C++[
^]
Reading Excel files using ODBC[
^]
How to Read and Write Excel Files in C++ via ADO[
^]
There are lots of ways to interact with excel, if you have to do it in C++ then the way to go is to read the values in the excel file, open a text file in order to write data into it and translate the excel file as you need to store the values into the text file... you know your requirements so you will have to finish your design to implement your needs, but basically you have to reach access to the excel file, open a text file and store data inside to follow the php requirements.
Hope this helps!