简体   繁体   中英

PHP code to Read excel file uploaded to google app engine cloud storage bucket

Basically, I need to read contents of the excel file uploaded to the GCS bucket and import data to the database. All this will be done by a Cron.

But, when I am trying to read the file using the code below:

    $reader = PHPExcel_IOFactory::createReaderForFile("gs://" . $this->bucketName . "/1476025006_testManager.xlsx");
    $reader->setReadDataOnly(false);
    $objXLS = $reader->load("gs://" . $this->bucketName . "/1476025006_testManager.xlsx");

    $arrData = $objXLS->getActiveSheet()->toArray();

    print "<pre>";
    print_r($arrData);
    print "</pre>";

I am getting an empty array.

Array
(
    [0] => Array
        (
            [0] => PK
        )

)

I am using PHPExcel library to read the excel file and insert the contents into the database. When I execute the same code on local instance of wamp, it works fine. What is the proper way to read contents of excel file from the google cloud storage bucket using PHP ?

Thanks

I was able to resolve this issue by uploading and parsing contents of xls file instead of xlsx file.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM