0

i have excel file downloaded from web and its protected.
if i open that file and disable protection PHPExcel_IOFactory::load can open it
but there is anyway to PHPExcel unprotect file itself?
because i want my php code to download it automatically and open it
but if i cant set file unprotected by PHPExcel i must download it
set disable protection and then give it to PHPExcel_IOFactory::load
and its bad
my code:

 $inputFileName = './sampleData/ttt.xlsx';
    echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
    $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);


    echo '<hr />';

    $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);

so PHPExcel have any function or class for unprotect file itsself? and sorry for my bad english

  • So what happens when you try to load the file using PHPExcel without disabling protection? – Mark Baker Dec 12 '15 at 17:16
  • its show noting Array ( [1] => Array ( [A] => ) ) – user1772630 Dec 12 '15 at 17:20
  • I've no idea how this file is protected, but the PHPExcel Reader should throw an exception if it can't read the file.... your code should never even get to the `toArray()` call..... can you send my a copy of this `ttt.xlsx` file that can be read without error but that doesn't show any data at all – Mark Baker Dec 12 '15 at 17:36
  • http://members.tsetmc.com/tsev2/excel/MarketWatchPlus.aspx?d=0 this is where you can download but when i disable protection its work perfectly – user1772630 Dec 12 '15 at 17:54
  • The issue is nothing to do with the file being protected in any way, because the file isn't protected in any way. Modern versions of MS Excel simply switch the Excel GUI to a protected mode when you load a file that has been downloaded from the internet. – Mark Baker Dec 12 '15 at 18:33
  • This issue is something inside the file, and I'm still investigating what that might be (it wasn't created by MS Excel)... but when you open and save it again in MS Excel, it creates a correctly formatted file that PHPExel is capable of reading – Mark Baker Dec 12 '15 at 18:35
  • but i have micosoft excel 2010 and when i disable protection PHPexcel start working ...what i must to do .. :( – user1772630 Dec 12 '15 at 19:03
  • and belive me file is protected i see it in my window see this picture http://uupload.ir/files/x3j7_capture.jpg and this on Microsoft excel http://uupload.ir/files/1t57_capture2.jpg when i click on enable editing its start working ... – user1772630 Dec 12 '15 at 19:05
  • No, there is NO protection on the file itself...... As I said "`Modern versions of MS Excel simply switch the Excel GUI to a protected mode when you load a file that has been downloaded from the internet`" That is not the same as a protected file, which would be password protected to prevent it from being read by anybody without the password – Mark Baker Dec 12 '15 at 19:16
  • so its must have headers in files or something like that there is anyway i can solve it? – user1772630 Dec 12 '15 at 19:17
  • NO!!! It's nothing to do with headers in the file. I'm looking at the file itself at the moment..... it looks like it's using a non-standard namespacing, which causes problems for PHPExcel because it is "non-standard" – Mark Baker Dec 12 '15 at 19:18
  • so i cant do anything about it right? – user1772630 Dec 13 '15 at 17:54
  • Unless you rewrite the PHPExcel Reader to work with non-standard namespaces, then there's nothing that you can do.... it's an overhead that slows the Reader down, and very few Excel files are affected anyway (only a few of those generated by some 3rd-party applications other than MS EXcel itself) – Mark Baker Dec 13 '15 at 18:05

0 Answers0