Go Back   Forums > Community Chatterbox > Tech Corner > Programming
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

Reply
 
Thread Tools Display Modes
Old 17-09-2005, 03:52 PM   #1
Reup
10 GOSUB Abandonia
20 GOTO 10
 
Reup's Avatar

 
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
Default

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' k:

If someone else has nifty classes they wrote or know about, I'd like to hear about them (links to if you got 'em)!
Reup is offline                         Send a private message to Reup
Reply With Quote
Old 18-09-2005, 10:15 AM   #2
Data
retired
 
Data's Avatar


 
Join Date: Jun 2004
Location: Jan Mayen, Svalbard and Jan Mayen
Posts: 2,167
Default

indedd handy.
__________________
Flowing with the stream of life
Data is offline                         Send a private message to Data
Reply With Quote
Old 19-09-2005, 07:18 AM   #3
Reup
10 GOSUB Abandonia
20 GOTO 10
 
Reup's Avatar

 
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
Default

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;
}
Reup is offline                         Send a private message to Reup
Reply With Quote
Reply


Similar Threads
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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 04:05 AM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.