2009年1月21日 星期三

用Spreadsheet_Excel_Writer讓cell裡的字換行

用Spreadsheet_Excel_Writer讓欄位像上圖一樣

require_once("PEAR/Writer.php");
//Excel檔名
$filename = "ExcelTest.xls";
$sheet_1 = "SHEET1";
$analys =new Analyse;
$workbook = new Spreadsheet_Excel_Writer(); //新增Excel
//sending HTTP headers
$workbook->send($filename);
$worksheet =& $workbook->addWorksheet($sheet_1); //新增sheet
$format_title_1 =& $workbook->addFormat();
$format_title_1 ->setTextWrap(); //折行
// \n和\x0A 指ALT+Enter
$worksheet->write(0,0,"這是\ntest",$format_title_1);
$worksheet->write(0,1,"這是\x0A測試",$format_title_1);
$workbook->close();

沒有留言: