首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用fromArray为大量数据生成.xlsx文件

使用fromArray为大量数据生成.xlsx文件
EN

Stack Overflow用户
提问于 2019-01-29 17:39:16
回答 1查看 442关注 0票数 0

我需要使用fromArray()在一个大约111.100行的.xlsx文件中编写代码,但是我遇到了一个奇怪的错误

我使用phpspreadsheet库

代码语言:javascript
复制
        $spreadsheet = new Spreadsheet();
        $sheet = $spreadsheet->getActiveSheet();
        $columnLetter = 'A';
        foreach ($columnNames as $columnName) {
            // Allow to access AA column if needed and more
            $sheet->setCellValue($columnLetter.'1', $columnName);
            $columnLetter++;
        }
        $i = 2; // Beginning row for active sheet
        $columnLetter = 'A';
        foreach ($columnValues as $columnValue) {
            $sheet->fromArray(array_values($columnValue), NULL, $columnLetter.$i);
            $i++;
            $columnLetter++;
        }
        // Create your Office 2007 Excel (XLSX Format)
        $writer = new Xlsx($spreadsheet);

        // In this case, we want to write the file in the public directory
        // e.g /var/www/project/public/my_first_excel_symfony4.xlsx
        $excelFilepath =  $directory . '/'.$filename.'.xlsx';

        // Create the file
        $writer->save($excelFilepath);     

我得到了一个例外:

消息:“无效的单元坐标AAAA18272”

#代码:0#文件:"./vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php“

你能帮帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2019-02-06 16:48:33

Excel页面有限。限制是巨大的,但仍然是有限的。这是一个正确的筛选器,因此如果没有空间,您将无法写入。无论如何,您不应该使用excel页面来处理如此大量的数据,您可以尝试将其分成较小的片段,但数据库应该是处理这些大量信息的方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54417948

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档