Every so often, I am reminded why I should never become an IT consultant (not considering the fact I am wholly unqualified). I was writing some nifty (for me) php scripts to generate a table of scoring data from a mysql database table. I got everything to output just the way I wanted it but since I’m not the primary end user, I decided to have the end user test it. A couple of minor mods and then I got hit with the “I want to print it out like I used to do with Excel” request.
So I fiddled with the css, stuck the page-break-before styling in, and carried the header through the pagination. Got everything working and looking great when I got hit with the “Does it have to be 4 pages long?” Ugh.
Now if all the data was stored in the database table, I could just dump the table into a csv file and be done with it but that wasn’t the case. The script computed the bulk of the data. So I figured if I could dump the data into a csv file as it was being generated, the end user could just import it into Excel and manipulate/print it as his Excel skills allowed. I found this nice little tutorial which gave me the information I needed to modify my script quickly and most importantly, without trial and error.