gunther_maier has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I would appreciate help with the following problem:

Situation:

I download some data via a weblink, which in my web browser I can either save as XLSX-file or open in Excel. In the latter case, the file opens in protected view and I need to click the button "Enable Editing".

What I want to do:

I want to download this file and extract some information from it all in a Perl script. I have mastered downloading with the help of LWP::Simple, but cannot find a way to read the information from the Excel file without manually opening it, clicking "Enable Editing" and saving it again. Once this is done, I can read the content without problems with Spreadsheet::XLSX.

Many thanks
Gunther Maier

Replies are listed 'Best First'.
Re: Problem reading Excel File
by Corion (Patriarch) on Feb 10, 2016 at 11:43 UTC

    Without seeing code, we can only guess. My suggestion is to (re)read binmode and to apply it to the filehandle before writing the file to disk.

    Also, have you compared that the file your Perl script saves is identical to the file if saved (for example) from a web browser?

Re: Problem reading Excel File
by Yary (Pilgrim) on Feb 10, 2016 at 13:03 UTC
    One of the most popular modules on CPAN is Spreadsheet::ParseExcel - and if that isn't a good fit, there are other Excel reading & writing modules out there. Search, find, install, and enjoy!
      Oooops, sorry.... this is a Windows permission thing. Have you tried running your script from a prompt with Administrator permissions?

      I suspect you may need to look at the Win32 modules and figure out what system calls will unlock the downloaded file.

      and if that is a dead end, you can control Excel via its scripting interface, have it set the "Enable editing" flag for you.

Re: Problem reading Excel File
by gunther_maier (Initiate) on Feb 10, 2016 at 15:49 UTC

    Many thanks! Win32 did the trick.

      how did you solve your problem?