Dynamic Invoice Creation and Export

Posted on 2007-10-15
Last Modified: 2008-02-07

I have created an online invoice system, which stores details of all of our invoices, we need to develop a system for veiewing them online (which will be a simple php dynamic page) and also for exporting them.

I have looked at a few options, like creating and excel file but cant seem to find the right avenue to follow.

I am looking for as much advice as possible on possible ways of dealing with this.  

We have our invoice template (currently in excel) which fits an a4 sheet, we only really need 2 results, 1 the invoice we can view online (easy with php) and an excel or pdf version file that we can store on a local directory and print hard a hard copy from.

We have talked about creating a version online which could be printed but really we are a bit lost with regards the bes way to go about this, any advice would be much appriciated

Many thanks

Question by:socross
    LVL 6

    Accepted Solution

    One word.


    an excel spreadshit is nothing more then a <table></table>

    If you display your contents inside a table, and have php output the file name as xls, Windows would automatically associate that generated file with Excel.

    remember the following lines

    header( "content-type: text/xml" );

    If you want the simple method, use <table><th></thj> ...

    If you want to do it with the completely compatible version of Excel following this link

    I would suggest you do it the simple way first. because the ibm page involves lots of MS documents related text input and coding. It'll be difficult to see your errors in this situation if all that hassle was caused by a typo.

    LVL 1

    Author Comment

    Ok Sounds Good
    Couple of questions

    Our Invoice Template does contain a couple of images but could easily be creatd using tables.

    COuld you be a bit clearer with regads the steps involved.


    1 Dynamically generate invoice based on table the layout you reccomened (woud this need to be based on an a4 sheet).

    Then What? COuld yu run through what steps would be required (i need a verison online and a version i can pdf)
    If i can create an excel version server side, is it possible to automatically pdf it before i download it??

    Thanks for your quick responce.

    LVL 6

    Expert Comment

    you are now mixing technologies.

    if you really want to pdf something on the server side, you might want to call up MS Office scripting.

    Basically, you tell the server to start Excel, fill in all the data, (this includes where to click), print it to pdf, where to safe the pdf, and then provides a link to the pdf in php.

    that's a more complicated method, since it involves way more things then expected. I strong advise against it unless you are sure of either of the following.

    1, you site's traffic is so light that no two person can create a pdf at the same time.  Else one might be forced to wait while the other gets all the attention, and their file is wiped once the 2nd one starts to run.

    2. you generate pdfs and store them on your web server. and would only remove them after a certain time. Then just use a cron system, it is way better.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now