PHP-General - Generate Word doc from php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sabatier
Forum Newbie
Posts: 6
Joined: Thu Aug 23, 2007 5:40 am

PHP-General - Generate Word doc from php

Post by sabatier »

Hi, I'm doing a college project which involves automatically generating student transcripts from a MySQL database. I want to be able to create a system whereby the user enters the student no, and a Word document is automatically generated which displays the student's results in a a letter format. I am able to create the Word document no problem; it's the formatting that I'm having trouble with. If, say, the student is in fourth year, then the Word document must display four sets of results, like below:

This is to certify that Daffy Duck obtained the following results in bla bla bla:

First year: Second Year:
Subject 1 78 Subject 1 78 (Note in the actual document, there'd be proper spacing between the subjects and marks)
Subject 2 64 Subject 2 64
Subject 3 12 Subject 3 12
Subject 4 58 Subject 4 58
Subject 5 86 Subject 5 86
Subject 6 7 Subject 6 7

Overall: 99 Overall 99

Third Year: Fourth Year:
Subject 1 42 Subject 1 42
Subject 2 75 Subject 2 75
Subject 3 64 Subject 3 64
Subject 4 45 Subject 4 45
Subject 5 67 Subject 5 67
Subject 6 15 Subject 6 15
Subject 7 42

Overall 99 Overall 99

So my question is this: What's the best way to generate a Word document like above where four year's results will neatly fit on one page? Should I do a HTML template within PHP or have some mechanism to paste the data into a Word template? Or is there a better way to do it?

I'd really appreciate your suggestions!

sabatier
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Does it have to be Microsoft word?

If so I would say try using the Messy RTF Document format.

Or it it doesn't have to be Microsoft Word, i would Say use PDF.

(Note RTF documents can be converted to PDF)
Post Reply