开发者

spreadsheet excel writer 9.2

开发者 https://www.devze.com 2023-03-14 00:13 出处:网络
I am using spreadsheet_excel_writer(9.2) to download an excel file from a mysql (4.1.22) database. I have done this successfully on the same server, and this code is very similar, but on this occasion

I am using spreadsheet_excel_writer(9.2) to download an excel file from a mysql (4.1.22) database. I have done this successfully on the same server, and this code is very similar, but on this occasion it isn't working. I get an excel file that has the data in it but all in one cell with all sorts of characters intermingled. Does anyone have any idea what the problem could be? I have been making alterations and re-testing for days now. I would really appreciate it if someone could spot something that I am not seeing.

   <?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->wr开发者_StackOverflow社区ite($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();
?>

This is the resultant worksheet:

ÐÏࡱá;þÿ

þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

 s@Gert MrClann Credogert@clanncredo.ie 2011-06-17°s@Jim MaherDirectorTrigraph 01-6390050087-6261422jim@trigraph.ieð?

2011-06-17Às@MichaelMcKennaPrincipal Consultant SmartCloud@ì̘TBmmckenna@smartcloud.ieð?

2011-06-17Ðs@LiamConnolly ConsultantCapricornVentis6¦ÊA#liam.connolly@capventis.comð?

2011-06-17às@MinhajShaikh MrNCIapnaminhaj@hotmail.comð? 2011-06-17> ¶ Root Entryÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ


S_E_W is deadware. You should switch to PHPExcel at some point, especially if you want support for something newer than BIFF 5.0 files (Excel 5.0).

Check that your query is working correctly and produces a proper $row. And try to avoid extract() like the plague. It's almost as horrible an idea as register_globals was and lets you reproduce the exact same problems that register_globals caused in the first place. It's not much more work to type out $row['id'], $row['name'] etc..., and saves you the annoyance of overwriting other variables you were using for other purposes BEFORE doing the extract() call.

0

精彩评论

暂无评论...
验证码 换一张
取 消