Web Engine
Language:
ru
en
Welcome
Templates and Database
GD2 Thumbnails
JQuery, AJAX and JS templates
Table
PDF
XLS
Debuger for JS and PHP
Captcha
Configs
XLS Read/Write examples ( lib/xls/* )
Description
Spreadsheet_Excel_Reader library is used for reading xls format. Johann Hanne`s WriteExcel library is used for writing xls format.
Example
HTML code
<key:read>
PHP code
if($_POST[write]){ require_once "lib/xls/class.writeexcel_workbook.inc.php"; require_once "lib/xls/class.writeexcel_worksheet.inc.php"; $fname = tempnam("/uploaded/tmp", "example.xls"); $workbook = &new writeexcel_workbook($fname); $worksheet1 =&$workbook->addworksheet('Sheet1'); $worksheet1->write(0, 0, "10*10 multiplay", null); $worksheet1->write(1, 0, "", $heading); for($i=1;$i<=10;$i++){ for($j=0;$j<10;$j++){ $worksheet1->write($i+1, $j, $i*($j+1), null); } } $workbook->close(); header("Content-Type: application/x-msexcel; name=\"example.xls\""); header("Content-Disposition: inline; filename=\"example.xls\""); $fh=fopen($fname, "rb"); fpassthru($fh); unlink($fname); exit; }else if($_POST['read']){ require_once 'lib/xls/reader.php'; // ExcelFile($filename, $encoding); $data = new Spreadsheet_Excel_Reader(); // Set output Encoding. $data->setOutputEncoding('CP1251'); $data->read("uploaded/tmp/example2.xls"); $arr = $data->sheets[0]['cells']; $res=""; while(list($key,$val)=@each($arr)){ while(list($key2,$val2)=@each($val)){ $res.=$val2."| "; } $res.=""; } $t->replace("read",$res); }
Copyright © 2010
Apycom jQuery Menus