tags:

views:

866

answers:

5

How can I produce printable reports from a database?

I need to print 1 or two reports per page with about 300 reports.

I'd prefer free methods; I don't want to pay for a big report generator.

A: 

Do you need the reports to be dynamic or static?

What I mean is...

Is the report always going to be based on the same data values (Cost of whatever, number of whatever, date of whatever)... Or do you want something that you can plug in what you are wanting a report OF and have it print out the results?

This should be fairly simply using CSS and a decent browser that will render the CSS.

Unless of course you want graphics, like charts and whatnot. If that's the case, it's not the printing that's tricky, it's the rendering.

Anthony
I need to generate dynamic reports with tables, no graphics. How would I put "page breaks" in CSS?
A: 

I think you could go couple ways... as Anthony said you could very easily write a CSS to style the database results (aka reports) and keep everything completely web based. You could write a function / use various canned routines to export result sets to something that excel can easily render.

If you wish you derive graphs from your data sets then may I suggest using either ImageMagick (http://www.imagemagick.org/) or the GD Library (http://www.libgd.org/) in conjunction with PHP.

  • Nicholas
Nicholas Kreidberg
+2  A: 

I think you're looking for this CSS property:

http://www.w3schools.com/CSS/pr_print_pageba.asp

It allows you to set break points for your print result.

Luca Matteis
A: 

Google for "php scripts", and you'll find a bunch of sites with free script libraries. I've noticed dozens of database-driven table generators among them. Some offer the small additional step to format the tables for printing; or you probably could handle that yourself.

e.g. hotscripts
scripts

le dorfier
A: 

One good reporting tool is myDBR (www.mydbr.com). This is a reporting tool which is very easy to install and to integrate into your existing solution.

The reports are stored procedures which are executed by myDBR allowing you to very easily change the report content. It is also possible to procedure charts by just providing the data and requesting a chart to be drawn.

Wolfgang