xls file generation

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
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

xls file generation

Post by madhu »

Hi all,

Am Madhu, am trying to create an xls file in binary format which canbe opened through Microsoft Excel viewer.

Am able to create the xls file but the problem is, in the created xls file , the last field is unable to recognised by the excel viewer.

Am sending code.Please check and help me where couldbe the problem with my code.

Code: Select all

<?
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$dir = getcwd();
$today = date("ymdHi");
$today_display = date("m/d/Y H:i");
$source_file = $today.'.xls';
$remote_file = $today.'.xls';
$fname = tempnam($dir, $source_file);

$workbook = &new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet();

$worksheet->write(0, 0, 'USERID');
$worksheet->write(0, 1, 'PASSWORD');
$worksheet->write(0, 2, 'ADDRESS');
$worksheet->write(0, 3, 'CITY');
$worksheet->write(0, 4, 'COUNTRY');
$worksheet->write(0, 5, 'PIN');
$worksheet->write(0, 6, 'PHONE');
$worksheet->write(0, 7, 'FIRSTNAME');
$worksheet->write(0, 8, 'LASTNAME');
$worksheet->write(0, 9, 'COL_TIME');

$worksheet->write(1, 0, "email_id");
$worksheet->write(1, 1, "password");
$worksheet->write(1, 2, '' );
$worksheet->write(1, 3, "state");
$worksheet->write(1, 4, "country");
$worksheet->write(1, 5, '');
$worksheet->write(1, 6, '');
$worksheet->write(1, 7, "first_nm");
$worksheet->write(1, 8, "last_nm");
$worksheet->write(1, 9, "today_display");

$workbook->close();
$fh=fopen($fname, "rb");
chmod($fname,0777);
copy($fname, $dir.'/'.$source_file); //copy from temp to source file
?>

Thanks and regards
MADHU
Post Reply