|
![]() |
#1 | ||
![]() ![]() ![]() Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
|
![]() I've been using a couple of useful PHP classes I'd thought I'd share:
FPDF - A quick PDF creation class This is a really easy way to create good looking PDF documents on the fly! I've made colourfull tables and more with this in minutes! PHPMailer - Great mail class It has so many neat options! And recently discovered the benefit of using PEAR-classes as well! I've used Spreadsheet_Excel_Writer to create .XLS files really quickly. I've been digging through all the other PEAR-classes and there are so many that look great. If anyone's interested I'll post my generic MySQL-dataset to .XLS-'parser' If someone else has nifty classes they wrote or know about, I'd like to hear about them (links to if you got 'em)! |
||
![]() ![]() |
|
![]() |
#2 | ||
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2004
Location: Jan Mayen, Svalbard and Jan Mayen
Posts: 2,167
|
![]() indedd handy.
__________________
Flowing with the stream of life |
||
![]() ![]() |
|
![]() |
#3 | ||
![]() ![]() ![]() Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
|
![]() For anyone interested. This only works if PEAR is installed and configured on your server.
Code:
require_once 'Spreadsheet/Excel/Writer.php'; // $dataSet is any MySQL-query-result // $title is the file-name including the complete path // $MODE == 0 -> save as local file // $MODE == 1 -> send HTTP headers -> open in browser! only use in NEW file, or // the remaining HTML will be send to the sheet as well!!! function writeExcel( $dataSet, $title, $MODE ) { // Creating a workbook $filename = $title.'.xls'; $pathname = '.'; $workbook = new Spreadsheet_Excel_Writer( $pathname.$filename ); // Creating formats // Only bold in this case $format_bold =& $workbook->addFormat(); $format_bold->setBold(); // sending HTTP headers if $MODE is set to 1 if( $MODE == 1 ) $workbook->send($filename); // Creating a worksheet $worksheet =& $workbook->addWorksheet('SU5-Aanvragen'.$datum); // Writing column headers (bold) $numFields = mysql_num_fields( $dataSet ); for( $k = 0; $k < $numFields; $k++ ) { *$field = mysql_fetch_field( $dataSet, $k ); *$fieldName = $field->name; * *$worksheet->write( 0, $k, $fieldName, $format_bold ); } * //writing data, row for row (regular) for( $i = 0; $i < mysql_num_rows( $dataSet ); $i++ ) { *// starting form row 1, because row 0 is the header-row *$row = mysql_fetch_array( $dataSet ); *$index = $i + 1; *for( $k = 0; $k < $numFields; $k++ ) *{ * $worksheet->write( $index, $k, $row[$k], $formal_bold ); *} * } // return the filename! // Let's send the file $workbook->close(); return $pathname.$filename; } |
||
![]() ![]() |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
For Anyone Interested In Freeware Game Development News.. | chainsoar | Blah, blah, blah... | 2 | 07-10-2006 12:24 AM |
Need Development Web Server | Rogue | Programming | 1 | 11-05-2005 07:00 PM |
New "lucasarts" Adventure Game In Development | Flop | Gaming Zone | 3 | 12-04-2005 11:41 PM |
Future Development | vipin | Old Suggestions | 5 | 29-06-2004 12:05 PM |
|
|
||
  |