-2

When I open this xls with Microsoft Excel the next message appears: "The file format and extension of "proof.xls" do not match. The file could be corrupted or unsafe. Unless you trust its source, do not open it. Do you want to open it anyway?".

Microsoft Office opens the document anyway and let me save it as a new format, but I need this document to be readeable "on the fly" (without open and save file step with Excel) to load it with PHPExcel.

This file came from an automatic web generator and I don't know how exactly It's encoding the xls.

Here's a file structure extract (table with only the first row, can't paste here the entire file content):

   <?xml version="1.0" encoding="ISO-8859-1"?>
    <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:user="urn:my-scripts" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office"><ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"><WindowHeight>9345</WindowHeight><WindowWidth>15180</WindowWidth><WindowTopX>120</WindowTopX><WindowTopY>60</WindowTopY><ProtectStructure>False</ProtectStructure><ProtectWindows>False</ProtectWindows></ExcelWorkbook><ss:Styles><ss:Style ss:Name="titulo" ss:ID="titulo"><NumberFormat ss:Format="@"/><Alignment ss:WrapText="0" ss:VerticalText="0" ss:Vertical="Center" ss:ShrinkToFit="0" ss:Rotate="0.0" ss:ReadingOrder="LeftToRight" ss:Indent="0" ss:Horizontal="Center"/><ss:Interior ss:Color="Automatic" ss:PatternColor="Automatic" ss:Pattern="None"/><ss:Protection x:HideFormula="
0" ss:Protected="0"/><ss:Font x:Family="Automatic" ss:VerticalAlign="None" ss:Underline="None" ss:StrikeThrough="0" ss:Size="14.0" ss:Shadow="0" ss:Outline="0" ss:Italic="0" ss:FontName="Arial" ss:Color="Automatic" ss:Bold="1"/></ss:Style><ss:Style ss:Name="subtitulo-negrita" ss:ID="subtitulo-negrita"><NumberFormat ss:Format="@"/><Alignment ss:WrapText="0" ss:VerticalText="0" ss:Vertical="Center" ss:ShrinkToFit="0" ss:Rotate="0.0" ss:ReadingOrder="LeftToRight" ss:Indent="0" ss:Horizontal="Left"/><ss:Interior ss:Color="Automatic" ss:PatternColor="Automatic" ss:Pattern="None"/><ss:Protection x:HideFormula="0" ss:Protected="0"/><ss:Font x:Family="Automatic" ss:VerticalAlign="None" ss:Underline="None" ss:StrikeThrough="0" ss:Size="12.0" ss:Shadow="0" ss:Outline="0" ss:Italic="0" ss:FontName="Arial" ss:Color="Automatic" ss:Bold="1"/></ss:Style><ss:Style ss:Name="subtitulo" ss:ID="subtitulo"><NumberFormat ss:Format="@"/><Alignment ss:WrapText="0" ss:VerticalText="0" ss:Vertical="Center" ss:ShrinkToFit="0" ss:
Rotate="0.0" ss:ReadingOrder="LeftToRight" ss:Indent="0" ss:Horizontal="Left"/><ss:Interior ss:Color="Automatic" ss:PatternColor="Automatic" ss:Pattern="None"/><ss:Protection x:HideFormula="0" ss:Protected="0"/><ss:Font x:Family="Automatic" ss:VerticalAlign="None" ss:Underline="None" ss:StrikeThrough="0" ss:Size="12.0" ss:Shadow="0" ss:Outline="0" ss:Italic="0" ss:FontName="Arial" ss:Color="Automatic" ss:Bold="0"/></ss:Style><ss:Style ss:Name="cabecera-tabla" ss:ID="cabecera-tabla"><NumberFormat ss:Format="@"/><Alignment ss:WrapText="0" ss:VerticalText="0" ss:Vertical="Center" ss:ShrinkToFit="0" ss:Rotate="0.0" ss:ReadingOrder="LeftToRight" ss:Indent="0" ss:Horizontal="Center"/><ss:Interior ss:Color="Automatic" ss:PatternColor="Automatic" ss:Pattern="None"/><ss:Protection x:HideFormula="0" ss:Protected="0"/><ss:Font x:Family="Automatic" ss:VerticalAlign="None" ss:Underline="None" ss:StrikeThrough="0" ss:Size="11.0" ss:Shadow="0" ss:Outline="0" ss:Italic="0" ss:FontName="Arial" ss:Color="Automatic" ss:Bold="1"
/></ss:Style><ss:Style ss:Name="contenido-tabla" ss:ID="contenido-tabla"><NumberFormat ss:Format="@"/><Alignment ss:WrapText="0" ss:VerticalText="0" ss:Vertical="Center" ss:ShrinkToFit="0" ss:Rotate="0.0" ss:ReadingOrder="LeftToRight" ss:Indent="0" ss:Horizontal="Center"/><ss:Interior ss:Color="Automatic" ss:PatternColor="Automatic" ss:Pattern="None"/><ss:Protection x:HideFormula="0" ss:Protected="0"/><ss:Font x:Family="Automatic" ss:VerticalAlign="None" ss:Underline="None" ss:StrikeThrough="0" ss:Size="10.0" ss:Shadow="0" ss:Outline="0" ss:Italic="0" ss:FontName="Arial" ss:Color="Automatic" ss:Bold="0"/></ss:Style></ss:Styles><Worksheet ss:Name="ACTIVITAT OCUPACIÓ"><ss:Table ss:DefaultColumnWidth="120" x:FullRows="1" x:FullColumns="1" ss:ExpandedRowCount="64000" ss:ExpandedColumnCount="500"><Row><Cell ss:MergeDown="0" ss:MergeAcross="4" ss:StyleID="titulo"><Data ss:Type="String">LLISTAT ACTIVITAT OCUPACIÓ</Data></Cell></Row><Row><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="subtitulo-negrita"><Data 
ss:Type="String">Data inicial</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="subtitulo"><Data ss:Type="String">01/09/2015</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="subtitulo"><Data ss:Type="String"/></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="subtitulo-negrita"><Data ss:Type="String">Data final</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="subtitulo"><Data ss:Type="String">31/01/2016</Data></Cell></Row><Row><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="subtitulo-negrita"><Data ss:Type="String">Centre gestor</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="3" ss:StyleID="subtitulo"><Data ss:Type="String">105 - Facultat de Ciències de la Comunicació</Data></Cell></Row><Row><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="subtitulo-negrita"><Data ss:Type="String">Edifici/s</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="3" ss:StyleID="subtitulo"><Data ss:Type="String">Fac. Ciènc.  de la Comunicació</Data></
Cell></Row><Row><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Data inicial</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Hora inicial</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Data final</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Hora final</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Total hores</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Espai</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Estudi</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Activitat</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data 
ss:Type="String">Professor/Responsable</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Alumnes matriculats</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="cabecera-tabla"><Data ss:Type="String">Observacions</Data></Cell></Row><Row><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">01/09/2015</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">08:30</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">01/09/2015</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">21:00</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="Number">12.5</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">I/105EM/462</Data></Cell><Cell ss:MergeDown="0" 
ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String"/></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">02/09/2015</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">21:00</Data></Cell><Cell 
ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="Number">12.5</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">I/105EM/462</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String"/></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">Màster DCEI</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String">Chacon Garcia, Laura</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="Number">0</Data></Cell><Cell ss:MergeDown="0" ss:MergeAcross="0" ss:StyleID="contenido-tabla"><Data ss:Type="String"> </Data></Cell></Row>
</ss:Table><WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"><PageSetup><Header x:Margin="0"/><Footer x:Margin="0"/><PageMargins x:Top="0.984251969" x:Right="0.78740157499999996" x:Left="0.78740157499999996" x:Bottom="0.984251969"/></PageSetup><Selected/><FreezePanes/><FrozenNoSplit/><SplitHorizontal>5</SplitHorizontal><TopRowBottomPane>5</TopRowBottomPane><ActivePane>2</ActivePane><Panes><Pane><Number>3</Number></Pane><Pane><Number>2</Number><ActiveRow>4</ActiveRow><ActiveCol>2</ActiveCol></Pane></Panes><ProtectObjects>False</ProtectObjects><ProtectScenarios>False</ProtectScenarios></WorksheetOptions></Worksheet></Workbook>
JBoY
  • 51
  • 3
  • 13
  • 2
    No one is going to open your arbitrary binary file. Where did it come from? How was it created? Try to solve the *actual* problem here. – Jonathon Reinhart Oct 14 '15 at 09:51
  • Thanks for your recommendation and support @JonathonReinhart. – JBoY Oct 14 '15 at 10:05
  • Just because the answer you got wasn't the kind of answer you wanted doesn't mean it wasn't helpful. Seriously, no one is going to look at your possibly malicious file, so why not give us some details that may be actually helpful? – Jonathon Reinhart Oct 14 '15 at 10:07
  • I was not being ironic @JonathonReinhart, I was really grateful for your comment. It's always good to receive indications about how to behave in a community. :) – JBoY Oct 14 '15 at 11:11

1 Answers1

3

That's because it isn't an .xls file

.xls files are a binary format called BIFF, within an OLE2 wrapper.

The file that you've posted in part is a SpreadSheetML format file, an XML format that was introduced with Excel 2003, but that never proved particularly popular, and was later superceded by OfficeOpenXML (.xlsx) format.

It's a valid spreadsheet format, that MS Excel is perfectly capable of reading, but it isn't BIFF-format, hence the complaint that the extension doesn't match the format.

Change the extension to .xml and then read it in MS Excel.

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • Can I send you the entire file to know it's nature please? It's impossible to me to find a way to work with this file or to figure out how to change/export his content to a readable one. Thanks. – JBoY Oct 15 '15 at 12:28
  • It's a [SpreadSheetML](https://msdn.microsoft.com/en-us/library/aa140066(office.10).aspx) file. Try using PHPExcel's `Excel2003XML` Reader to load the file – Mark Baker Oct 15 '15 at 12:33
  • Though you may need to modify the Excel2003XML Reader to ignore the missing `''` – Mark Baker Oct 15 '15 at 12:40
  • Thanks a lot for your time, support and dedication to PHPExcel project @Mark Baker . I think I'm near to figure this out. I renamed my proof.xls doc to proof.xml and then commented the ''. Now I'm able to read the document but still having a Warning: Invalid argument supplied for foreach() in /home/www/si/excel_assignatures/reader/Classes/PHPExcel/Reader/Excel2003XML.php on line 402 – JBoY Oct 16 '15 at 08:53
  • The problem is that it isn't necessarily a valid SpreadSheetML file; the fact that it's missing the mso-application element of the XML confirms that.... I'm guessing that the styles aren't properly namespaced, and it really wants a custom version of the Reader – Mark Baker Oct 16 '15 at 09:07