In my previous project, one of the requirements was the system must be able to produce an official form document in Excel spreadsheet with precise formatting that will look consistent when printed. As reference, the client provided me a sample of the working form in an Excel spreadsheet that has been meticulously formatted using colors, font styles, borders and cell merging to produce the desired form document.

Using an Excel generator PHP library to produce the document would require too much work in terms of codes just to handle the formatting part. What we can do is use MS Excel to export the spreadsheet to HTML format. This process will generate a few HTML files based on the number of worksheets you have, a CSS file and image files (if any).

The main idea here is to let your application generate the HTML, CSS and image files exactly as the ones generated by Excel. And then use MS Excel to import the HTML files to render the spreadsheet. Since you’ll be offering a bunch of files for the user to download, it’s a good idea to bundle them up in a ZIP archive. This method should work on any programming languages.

Have a nice day!