dqgo99177 2011-06-20 15:53
浏览 28

电子表格excel writer 9.2

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->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();
?>

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ÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿ

  • 写回答

1条回答 默认 最新

  • doufen1933 2011-06-20 16:00
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法