Mike_Ro
@Mike_Ro
Python, JS, WordPress, SEO, Bots, Adversting

Как перебирать такие массивы/объекты?

Приветствую!

Пакетом phpoffice/phpspreadsheet прочел xls файл. При распечатке данного файла, получил следующего рода массив/объект:
5e78bc8a2acf8360423169.png

Часть кода

PhpOffice\PhpSpreadsheet\Spreadsheet Object
(
    [uniqueID:PhpOffice\PhpSpreadsheet\Spreadsheet:private] => 5e78bb128f18a5.54166568
    [properties:PhpOffice\PhpSpreadsheet\Spreadsheet:private] => PhpOffice\PhpSpreadsheet\Document\Properties Object
        (
            [creator:PhpOffice\PhpSpreadsheet\Document\Properties:private] => Microsoft Corporation
            [lastModifiedBy:PhpOffice\PhpSpreadsheet\Document\Properties:private] => Administrator
            [created:PhpOffice\PhpSpreadsheet\Document\Properties:private] => 844817553
            [modified:PhpOffice\PhpSpreadsheet\Document\Properties:private] => 1578905844
            [title:PhpOffice\PhpSpreadsheet\Document\Properties:private] => Untitled Spreadsheet
            [description:PhpOffice\PhpSpreadsheet\Document\Properties:private] => 
            [subject:PhpOffice\PhpSpreadsheet\Document\Properties:private] => 
            [keywords:PhpOffice\PhpSpreadsheet\Document\Properties:private] => 
            [category:PhpOffice\PhpSpreadsheet\Document\Properties:private] => 
            [manager:PhpOffice\PhpSpreadsheet\Document\Properties:private] => 
            [company:PhpOffice\PhpSpreadsheet\Document\Properties:private] => 
            [customProperties:PhpOffice\PhpSpreadsheet\Document\Properties:private] => Array
                (
                )

        )

    [security:PhpOffice\PhpSpreadsheet\Spreadsheet:private] => PhpOffice\PhpSpreadsheet\Document\Security Object
        (
            [lockRevision:PhpOffice\PhpSpreadsheet\Document\Security:private] => 
            [lockStructure:PhpOffice\PhpSpreadsheet\Document\Security:private] => 
            [lockWindows:PhpOffice\PhpSpreadsheet\Document\Security:private] => 
            [revisionsPassword:PhpOffice\PhpSpreadsheet\Document\Security:private] => 
            [workbookPassword:PhpOffice\PhpSpreadsheet\Document\Security:private] => 
        )

    [workSheetCollection:PhpOffice\PhpSpreadsheet\Spreadsheet:private] => Array
        (
            [0] => PhpOffice\PhpSpreadsheet\Worksheet\Worksheet Object
                (
                    [parent:PhpOffice\PhpSpreadsheet\Worksheet\Worksheet:private] => PhpOffice\PhpSpreadsheet\Spreadsheet Object
 *RECURSION*
                    [cellCollection:PhpOffice\PhpSpreadsheet\Worksheet\Worksheet:private] => PhpOffice\PhpSpreadsheet\Collection\Cells Object
                        (
                            [cache:PhpOffice\PhpSpreadsheet\Collection\Cells:private] => PhpOffice\PhpSpreadsheet\Collection\Memory Object
                                (
                                    [cache:PhpOffice\PhpSpreadsheet\Collection\Memory:private] => Array
                                        (
                                            [phpspreadsheet.5e78bb1299c594.91838894.A1] => PhpOffice\PhpSpreadsheet\Cell\Cell Object
                                                (
                                                    [value:PhpOffice\PhpSpreadsheet\Cell\Cell:private] => Пакет
                                                    [calculatedValue:PhpOffice\PhpSpreadsheet\Cell\Cell:private] => 
                                                    [dataType:PhpOffice\PhpSpreadsheet\Cell\Cell:private] => s
                                                    [parent:PhpOffice\PhpSpreadsheet\Cell\Cell:private] => PhpOffice\PhpSpreadsheet\Collection\Cells Object
                                                        (
                                                            [cache:PhpOffice\PhpSpreadsheet\Collection\Cells:private] => PhpOffice\PhpSpreadsheet\Collection\Memory Object
 *RECURSION*
                                                            [parent:PhpOffice\PhpSpreadsheet\Collection\Cells:private] => PhpOffice\PhpSpreadsheet\Worksheet\Worksheet Object
                                                                (
                                                                    [parent:PhpOffice\PhpSpreadsheet\Worksheet\Worksheet:private] => PhpOffice\PhpSpreadsheet\Spreadsheet Object
 *RECURSION*
                                                                    [cellCollection:PhpOffice\PhpSpreadsheet\Worksheet\Worksheet:private] => PhpOffice\PhpSpreadsheet\Collection\Cells Object
 *RECURSION*



Если понадобится, то могу приложить сюда весь результат работы скрипта, но там 8000 строчек...

Знаю, как перебирать массивы, но с таким впервые сталкиваюсь. Покажите пример перебора, плиз!
  • Вопрос задан
  • 111 просмотров
Решения вопроса 1
nokimaro
@nokimaro
Меня невозможно остановить, если я смогу начать.
Это не массивы. Для работы со строками столбцами и данными нужно использовать специальные методы (гетеры и тд) которые предоставляет данная бибилотека.

К сожалению Вам придётся всё-таки изучить документацию
https://phpspreadsheet.readthedocs.io/en/latest/

а так же можно ознакомится с примерами кода тут
https://github.com/PHPOffice/PhpSpreadsheet/tree/m...

Получить данные из ячейки или строки
https://phpspreadsheet.readthedocs.io/en/latest/to...
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы