电子表格excel编写器9.2


spreadsheet excel writer 9.2

我正在使用spreadsheet_excel_writer(9.2)从mysql(4.1.22)数据库下载excel文件。我在同一台服务器上成功地完成了这项工作,这段代码非常相似,但在这种情况下它不起作用。我得到一个excel文件,里面有数据,但都在一个单元格中,各种字符混杂在一起。有人知道可能是什么问题吗?我已经修改和重新测试了好几天了。如果有人能发现我没有看到的东西,我将不胜感激。

   <?php
require_once "/home/cloudare/php/Spreadsheet/Excel/Writer.php";
// Create workbook
$workbook =& new Spreadsheet_Excel_Writer();
// sending HTTP headers
$workbook->send('registration.xls');
// Create worksheet
$worksheet =& $workbook->addWorksheet('Registration Worksheet');
// Add DB connection script here
include("dbinfo.inc.php");
include("functions.inc.php");
$from=$_POST['from'];
$to=$_POST['to'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT * FROM register WHERE  date BETWEEN  '$from'  AND  '$to'" ;
$result = mysql_query($query);
//$result = do_query($query,__LINE__);
// Loop through the data, adding it to the sheet
while($row = mysql_fetch_assoc($result))
{
  $array[] = $row; 
    extract($row);
    $worksheet->write($currentRow,0,$id);
    $worksheet->write($currentRow,1,$name);
    $worksheet->write($currentRow,2,$last);
    $worksheet->write($currentRow,3,$title);
    $worksheet->write($currentRow,4,$company);
    $worksheet->write($currentRow,5,$phone);
    $worksheet->write($currentRow,6,$mobile);
    $worksheet->write($currentRow,7,$email);
    $worksheet->write($currentRow,8,$cloud);
    $worksheet->write($currentRow,9,$participant);
    $worksheet->write($currentRow,10,$date);
    // Remember Excel starts counting rows from #1!
    $excelRow = $currentRow + 1;
    $currentRow++;
}
$workbook->close();
?>

这是最终的工作表:

;þï

þ是的我是一个很有意思的人。爱奇艺

s@GertClann先生Credogert@clanncredo.ie2011-06-17°s@吉姆MaherDirector三角图01-6390050087-6261422jim@trigraph.ie?

2011年06月17日@MichaelMcKenna校长顾问SmartCloudTBmmckenna@smartcloud.ie?

2011年6月17日LiamConnolly顾问CapricornVentis6指定A#liam.connolly@capventis.com?

2011-06-17às@MinhajShaikhMrNCIapnaminhaj@hotmail.com?2011-06-17>¶根条目

S_E_W为自重。您应该在某个时候切换到PHPExcel,特别是如果您希望支持比BIFF 5.0文件(Excel 5.0)更新的文件

请检查您的查询是否正常工作并生成正确的$行。尽量避免extract()像瘟疫一样。这几乎和register_globals一样可怕,让您重现register_globals最初引起的完全相同的问题。只需键入$row['id']$row['name']等就可以了,而且在执行extract()调用之前,可以省去覆盖用于其他目的的其他变量的麻烦。