Report writing in PHP - what tools for making formating nice?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Smithz

    Report writing in PHP - what tools for making formating nice?

    Hi there,

    A client of mine wants to start generating some reports from their PHP /
    MYSQL database.

    They were previously gathering data from the screen and cutting and pasting
    it into a Word document template. They now just want to generate it.

    My initial thoughts are to just format the information in a table and then
    they print it out. But due to the dynamic nature of the reports and what is
    included, there might be issues with regard to the width fitting on a piece
    of paper, and the general format will not look as good as a Word document
    would.

    What ways could I approach this problem? Is there anything available which
    would make report formatting attractive and easy?

    Thanks in advance.

    Kind regards

    Dave


  • NC

    #2
    Re: Report writing in PHP - what tools for making formating nice?

    Dave Smithz wrote:[color=blue]
    >
    > A client of mine wants to start generating some reports from their PHP /
    > MYSQL database.
    >
    > They were previously gathering data from the screen and cutting and pasting
    > it into a Word document template. They now just want to generate it.
    >
    > My initial thoughts are to just format the information in a table and then
    > they print it out. But due to the dynamic nature of the reports and what is
    > included, there might be issues with regard to the width fitting on a piece
    > of paper, and the general format will not look as good as a Word document
    > would.
    >
    > What ways could I approach this problem? Is there anything available which
    > would make report formatting attractive and easy?[/color]

    You can generate reports in either PDF or RTF.

    The exact approach to generating PDF would depend on what PDF
    generation tool(s) you use. There are at least two PDF generation
    extensions bundled with PHP; there are also "pure PHP" tools such as
    FPDF that are somewhat slower, but do not require any particular PHP
    extension to be available (helpful for hosted applications).

    If you want to use RTF (which is readable by most word processors)
    instead, take a look here:



    This is my old post to alt.php where I show how to build a simple
    "report" (actually, a set of mailing labels) without having to learn a
    lot about RTF.

    Cheers,
    NC

    Comment

    • Colin McKinnon

      #3
      Re: Report writing in PHP - what tools for making formating nice?

      Dave Smithz wrote:

      <snip>[color=blue]
      >
      > My initial thoughts are to just format the information in a table and then
      > they print it out. But due to the dynamic nature of the reports and what
      > is included, there might be issues with regard to the width fitting on a
      > piece of paper, and the general format will not look as good as a Word
      > document would.
      >[/color]

      Three letters: CSS
      [color=blue]
      > What ways could I approach this problem? Is there anything available which
      > would make report formatting attractive and easy?
      >[/color]

      You could do all sorts of things to make it look fancy in print.....but why?
      Yes, we all know people for whom an Email isn't real unless its in black
      and white on A4 - even if its spam. But choosing this as your starting
      point reinforces this kind of behaviour instead of solving it.

      PDF is better, but instead of dead tree - it's dead data. An HTML table
      (yes, I do mean table - I know you can create fancy layouts with CSS and
      don't need tables to do it but....) can be imported back into a
      spreadshseet or a PHP array.

      Don't kill your data - give it a nice new home!

      C.

      Comment

      • Chung Leong

        #4
        Re: Report writing in PHP - what tools for making formating nice?

        Dave Smithz wrote:[color=blue]
        > My initial thoughts are to just format the information in a table and then
        > they print it out. But due to the dynamic nature of the reports and what is
        > included, there might be issues with regard to the width fitting on a piece
        > of paper, and the general format will not look as good as a Word document
        > would.[/color]

        Try using point sizes to specify the dimensions of the table cells. A
        point is 1/72 of an inch. If you specify the width of a table to be
        468pt, then in theory, the browser would print it out at exactly 6.5
        inches. CSS gives you a lot of control over the appearance, but there's
        no guarantee of WYSIWYG.

        Comment

        • Dave Smithz

          #5
          Re: Report writing in PHP - what tools for making formating nice?

          Thanks for the comments. I have been reading more and at first I thought the
          RTF file generation would be perfect.

          The reason why CSS is not suitable is because I need to generate these
          reports into a format that is sent back to clients. They need them in a
          particualr format and I could not really mess around with CSS trying to get
          it write. Plus they want to be sent a file via email or hard copy so RTF or
          PDF would be easier.

          On reading up I thought RTF would be great because of the dynamic nature of
          the required reports. I could create an RTF document template with a table
          in it. Look how a new table row is created. And for each table row I want to
          add to the report, just add the necessary RTF commands and fill it with
          data.

          However looking at an RTF document in raw text and working out how to add a
          new table line with data does not seem stright forward. I do not really
          fancy spending a lot of time learning about RTF.
          I did try and save Word document in XML format. This might be easier to
          figure out how to add new lines to a table and populate the table with
          report data. I can assume my clients are using Word 2003 so they would be
          able to read these document (worse case I could print them out as PDF before
          sending).

          I think I am going the right way about this but any other suggestions or
          ways to make adding a line to the XML or RTF would be welcome.

          Kind regards

          Dave


          Comment

          • Dave Smithz

            #6
            Re: Report writing in PHP - what tools for making formating nice?

            Hmmm,
            Even playing around with the XML strucutre although I managed to create
            another row by editing the raw text, when I think about it, I Also have
            dynamic anount of columns in the report depedning on what is needed to be
            generated. Having to learn and create functions that handle the dynamic
            generation of the correct XML (therefore the correct amount of columns and
            the amount of rows) might make things a bit tricky.

            Opoen to other easier ways of approaching this. Maybe for now it will just
            be printer HTML tables but I just do not think my clients will be happy with
            this.

            Kind regards

            Dave


            Comment

            • HappyHourHotSpots.com

              #7
              Re: Report writing in PHP - what tools for making formating nice?

              Can you just make a file in Word and then just export the data to a
              file that Word will read? Kind of like when you are doing envelopes
              and labels setup? This way you can layout the whole thing the way you
              have been in word and the text document will import the exported file
              and look exactly how it has in the past...

              Just a suggestion.

              -Rick

              --------------------------
              Looking for a place to go to happy hour tonight? Check out
              HappyHourHotSpo ts.com!

              Comment

              Working...