Using Phpexcel to read network files

Source: Internet
Author: User
There is no problem reading the local file. Change to read Web file
Could not open Xxx.xls for reading! File does not exist.

File_exists error. If you change to file_get_contents () the data is not properly removed. Solutions


Reply to discussion (solution)

He's using file_get_contents.

        Public function read ($sFileName)        {                //Check If file exists and is readable                if (!is_readable ($sFileName)) {
  throw new Exception ("Could not open". $sFileName. "For reading! File does not exist, or it was not readable. ");                Get the file data                $this->data = file_get_contents ($sFileName);

Boss.
is first
if (!file_exists ($pFilename)) {
throw new Phpexcel_reader_exception ("Could not open".) $pFilename. "For reading! File does not exist. ");
}

Here's an error I added a sentence!file_exists ($pFilename) &&! file_get_contents (' xxx ')

There's no error here.
Immediately following execution
$ole = new Phpexcel_shared_oleread ();

Get Excel Data
$res = $ole->read ($pFilename);

Here is the Read method
if (!is_readable ($sFileName)) {
throw new Phpexcel_reader_exception ("Could not open".) $sFileName. "For reading! File does not exist, or it was not readable. ");
}

Here is another error. did not see $this->data = file_get_contents ($sFileName); Excuse me, where did you find this? Is the version changed?

Good, I said file_get_contents not in your second place under the error?

File_get_contents can handle binary files safely, so you can read Excel files with file_get_contents

But if it is remotely read, because of the network and the other side of the cause, the probability of failure is quite large
Or should I read it back to the local temp file?

Hey. Looks like we're going to change the code. Phpexcel can read the array processing directly. Use file_get_contents only to make a string. It's all going to be corrected in the logical process.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.