【发布时间】:2018-03-31 15:14:36
【问题描述】:
我正在尝试读取存储在 AWS S3 存储桶中的一些 Excel 文件,但由于某些奇怪的原因,我遇到了 .XLSX 文件的问题,并且似乎 .XLS 文件的行为本身。
我在堆栈溢出中尝试了大多数答案,但我认为这与 s3 的流式处理功能有关。
$xls_obj = array(
'Bucket' => $attributes->report_bucket->StringValue,
'Key' => $attributes->report_key->StringValue
);
$s3 = S3Client::factory(awsCred());
$s3->registerStreamWrapper();
$file = 's3://'.$xls_obj['Bucket'].'/'.$xls_obj['Key'];
这将返回我可以访问的文件路径。文件。 然后我将它加载到我的 PHPExcel 文件中。当我尝试识别它时,它显示为 HTML,而 .XLS 文件显示为 excel5。
我确实尝试过使用
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
和
$reader = PHPExcel_IOFactory::createReaderForFile($file);
$reader->setReadDataOnly(true);
return $reader->load($file);
这显然给了我
DOMDocument::loadHTML(): Invalid char in CDATA 0x3 in Entity, line: 1
因为识别的格式是 HTML 我无法让它与来自 S3 的 PUBLIC URL 一起工作。所以我需要帮助!
【问题讨论】:
标签: php amazon-web-services amazon-s3 phpexcel