Print in XL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eskio
Forum Commoner
Posts: 66
Joined: Tue Apr 01, 2008 1:00 am

Print in XL

Post by eskio »

I want to print a MS Excel unsing PHP.
I can print a web page in xl format (see the code below). That is not my question?

Code: Select all

<html>
<head>
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
 
if (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$useragent)) {
    $browser = 'IE';
} elseif (preg_match( '|Opera ([0-9].[0-9]{1,2})|',$useragent)) {
    $browser = 'Opera';
} elseif(preg_match('|Firefox/([0-9\.]+)|',$useragent)) {
        $browser = 'Firefox';
} elseif(preg_match('|Safari/([0-9\.]+)|',$useragent)) {
        $browser = 'Safari';
} else {
        // browser not recognized!
    $browser_version = 0;
    $browser= 'other';
}
 
switch ($browser){
case 'IE':
    header('Content-Type: application/vnd.ms-excel'); //IE and Opera  
    break;
case 'Opera':
    header('Content-Type: application/vnd.ms-excel'); //IE and Opera  
    break;
default:
    header('Content-Type: application/x-msexcel'); // Other browsers  
} // switch ($browser)
header('Expires: 0');  
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');  
?>
 
<title>Print Log File</title>
</head>
<body>
<table width="300" border="1" cellspacing="3" cellpadding="3">
  <tr>
    <th scope="col">Name</th>
    <th scope="col">Age</th>
  </tr>
  <tr>
    <td>Alex</td>
    <td align="center"><p>22</p>    </td>
  </tr>
  <tr>
    <td>Tony</td>
    <td align="center">30</td>
  </tr>
</table>
</body>
</html>
I want to print a more complex page (printing in landscape, doing xl calculation etc.).Can someone tell me how to do it?

I want to know also if there is an xl API that allows me to access each cell of an xl sheet?
Thanks.
pradeep_kumar
Forum Newbie
Posts: 1
Joined: Tue Jul 22, 2008 7:31 am

Re: Print in XL

Post by pradeep_kumar »

U may use OLewriter class for it (free download from class org)
eskio
Forum Commoner
Posts: 66
Joined: Tue Apr 01, 2008 1:00 am

Re: Print in XL

Post by eskio »

Thanks
Post Reply