Login   Register  
PHP Classes

File: sql2excel.class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Erh-Wen,Kuo  >  sql2excel  >  sql2excel.class.php  >  Download  
File: sql2excel.class.php
Role: ???
Content type: text/plain
Description: This is the main class turning mysql sql content to excel.
Class: sql2excel
Easy way to stream Mysql sql content to Excel.
Author: By
Last change:
Date: 12 years ago
Size: 2,680 bytes


Class file image Download
	 * @version V1.0 2002/July/18 (c) Erh-Wen,Kuo (erhwenkuo@yahoo.com). All rights reserved.
	 * Released under both BSD license and Lesser GPL library license. 
	 * Whenever there is any discrepancy between the two licenses, 
	 * the BSD license will take precedence. 
	 * purpose: providing a easy method to write mysql sql content to excel file format and stream
	 *          the output to user's browser directly.

	class Sql2Excel{
		var $db_host;
		var $db_user;
		var $db_pwd;
		var $db_name;
		var $db_query;
		/*Sql2Excel is class constructor
		  Return: None
		function Sql2Excel($db_host="localhost",$db_user="",$db_pwd="",$db_name="")
			//connect mysql database
			$this->db_link=mysql_pconnect($this->db_host,$this->db_user,$this->db_pwd) or die("Mysql database connecion failed!");
		}//Sql2Excel() END
		/*ExcelOutput() is the key method to let this class works
		  This method won't work if you have not include "excelgen.class.php" well.
		  Return: None
		function ExcelOutput($query="")
			//connect mysql database
			//get result
			// now we could construct Excel output
			}// for($i=0;...) END
			//create new instance of ExcelGen() class
			$excel = new ExcelGen("Sql2Excel");
			//initiate a counter for excel "ROW" counter
			//write fields to excel
			}// for($i=0;...) END
				//fetch each Cell($rowscounter,$colscounter) into Excel output stream
					//identify field type to descide how to write excel cell
				}//for($colscounter..) END
			}// while($row=mysql..) END
		}//ExcelOut() END		
	}//class Sql2Excel END