Page 1 of 1

Print in XL

Posted: Tue Jul 22, 2008 4:26 am
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.

Re: Print in XL

Posted: Tue Jul 22, 2008 7:33 am
by pradeep_kumar
U may use OLewriter class for it (free download from class org)

Re: Print in XL

Posted: Thu Jul 24, 2008 6:49 am
by eskio
Thanks