我正在使用php_writeexcel-0.3.0
将数据导出到Excel。一切都很完美。但我只是注意到超过255的字符被截断。我也尝试过使用setversion()
功能。
是我使用的代码段
require_once "php_writeexcel-0.3.0/class.writeexcel_workbook.inc.php";
require_once "php_writeexcel-0.3.0/class.writeexcel_worksheet.inc.php";
//Export excel starts here
$fname = tempnam("/tmp", "Report.xls");
$workbook = new writeexcel_workbook($fname);
$worksheet = $workbook->addworksheet();
# Set the column width for columns 1, 2, 3 and 4
$worksheet->set_column(0, 0, 50);
# Create a format for the column headings
$header =& $workbook->addformat();
$header->set_bold();
$header->set_size(12);
$header->set_color('blue');
# Create a format for the stock price
$f_price =& $workbook->addformat();
$f_price->set_align('left');
$f_price->set_num_format('$0.00');
# Create a format for the stock volume
$f_volume =& $workbook->addformat();
$f_volume->set_align('left');
$f_volume->set_num_format('#,##0');
# Create a "vertical justification" format
$header->set_align('vjustify');
# Embedded newlines
$str2 = "Down\nHours";
$closedon =& $workbook->addformat();
$closedon->set_align('vcentre');
$closedon->set_text_wrap();
$f_change =& $workbook->addformat();
$f_change->set_align('vcentre');
$f_change->set_num_format('[Green]0.0%;[Red]-0.0%;0.0%');
$worksheet->write(0, 0, 'Work Order Number', $header);
$worksheet->write($SiNo, 0, $wo_number,$format2);
//$wo_number has more than 255 characters
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"Report.xls\"");
header("Content-Disposition: inline; filename=\"Report.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
这有什么解决方案吗?或者如果有任何其他codeigniter
库或更好的php库可用,请告诉我。