PHPExcel(BIFF)创建损坏的文件

时间:2015-10-19 17:06:20

标签: java php excel phpexcel xls

我使用PHPExcel创建旧的(XLS)Excel电子表格。它似乎正在工作,但如果要将生成的文件导入另一个Web应用程序(JAVA),则会出现以下错误:

Caused by: java.io.IOException: block[ 2 ] already removed - does your POIFS have circular or duplicate block references?

我的PHP代码如下所示:

require_once './lib/PHPExcel/PHPExcel.php';

$CustomObjectsHeader = array("CUSTOM_STRUCTURE_ID","NAME","LABEL","UPPER_STRUCTURE_VALUE_ID","STATE","VALUE_TEXT_01","VALUE_TEXT_02","VALUE_TEXT_03","VALUE_TEXT_04","VALUE_TEXT_05","VALUE_TEXT_06","VALUE_TEXT_07","VALUE_TEXT_08","VALUE_TEXT_09","VALUE_TEXT_10","VALUE_TEXT_11","VALUE_TEXT_12","VALUE_TEXT_13","VALUE_TEXT_14","VALUE_TEXT_15","VALUE_INT_16","VALUE_INT_17","VALUE_INT_18","VALUE_INT_19","VALUE_DATETIME_20","VALUE_DATETIME_21","VALUE_FLOAT_22","VALUE_FLOAT_23","VALUE_MEDIA_24","VALUE_MEDIA_25","VALUE_MEDIA_26","VALUE_MEDIA_27","VALUE_MEDIA_28","VALUE_MEDIA_29","VALUE_MEDIA_30","VALUE_MEDIA_31","VALUE_MEDIA_32","VALUE_MEDIA_33","VALUE_RICHTEXT_34","VALUE_RICHTEXT_35","VALUE_RICHTEXT_36","VALUE_RICHTEXT_37","VALUE_RICHTEXT_38","AFFILIATE");
$line = array("asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf adfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf","asdfasdf aasfasdfasdfas dfa sdfadfasdfadfasdf ads fasdfa dsfasdf asdfasdf asdf adsf asdf");
$CustomObjects = array($CustomObjectsHeader);
array_push($CustomObjects,$line);
array_push($CustomObjects,$line);

$excelDoc = new PHPExcel();
$excelDoc->setActiveSheetIndex(0);
$excelDoc->getActiveSheet()->fromArray($CustomObjects, null, 'A1');
$writer = PHPExcel_IOFactory::createWriter($excelDoc, 'Excel5');
$writer->save("test.xls");

如果我减少了数组内容的行数,它就可以正常工作。

如果我在Excel中打开生成的XLS文件并再次保存,JAVA-Webapp可以导入文件,即使它们非常大。

任何想法如何正确创建Excel?

0 个答案:

没有答案