note 45181 added to ref.com
| From: | dharm_shankar at rediffmail dot com | Date: | Sat, 28 Aug 2004 08:33:08 +0000 |
| Subject: | note 45181 added to ref.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75490@lists.php.net to get a copy of this message | ||
You can generate multiple sheets with these code
<?
$excel=new COM("Excel.Application");
$host="localhost";
$user = "root";
$passwd = "publish";
$db = "ihsa_hockey";
mysql_connect($host,$user,$passwd);
mysql_select_db($db);
$res_no_tab = mysql_list_tables($db);
$tot_tab = mysql_num_rows($res_no_tab);
$excel->sheetsinnewworkbook=$tot_tab;
$excel->Workbooks->Add();
$book=$excel->Workbooks(1);
$sheet_no=1;
while($tab_name = mysql_fetch_array($res_no_tab))
{
$sheetno = $sheet.$sheet_no;
$sheetno=$book->Worksheets($sheet_no);
$sheetno->Name=$tab_name[0];
$sheetno->activate;
echo "<b>Table Name : " .$tab_name[0]."</b>";
$fields = mysql_list_fields($db,$tab_name[0]);
$col=mysql_num_fields($fields);
$query="SELECT * FROM " . $tab_name[0];
$res=mysql_query($query);
$rr=1;
while($row = mysql_fetch_array($res))
{
echo "<br> Row :".$rr."<br>";
for($i=1;$i<=$col;$i++){
$c=$cell.$i;
$c=$sheetno->Cells($rr,$i);
$c->Activate;
$c->value = $row1[($i-1)];
echo "<b> col ".$i. " : </b>" .
$row[$i-1]."<br>";
}
$rr++;
}
echo "=====================END TABLE
".$tab_name[0]."===================================<br>";
}
$sheet_no++;
$book->saveas("c:\\debug.xls");
$book->Close(false);
unset($sheetno);
unset($book);
$excel->Workbooks->Close();
$excel->Quit();
unset($excel);
?>
----
Manual Page -- http://www.php.net/manual/en/ref.com.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45181
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45181&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45181&report=yes
Search -- http://master.php.net/manage/user-notes.php