0

I am currently working on a school project with a company, this company wants us to make a parser for many types of files.

At the moment we are at the excel to csv parsing, however it seems that if we try to do this, we will get gibberish. We do not get to use third party libraries, frameworks and such.

How can i still parse the excel files? Because all i get when i try to decode it, are gibberish lines.

[gibberish: https://hastebin.com/tuyuwiqaro.cpp]

Is there a way to get past this with PHP? We are first years, so we're unsure if this is past our skill level or if we can still do it.

ThatsAudio
  • 23
  • 1
  • 7
  • Excel isn't parsable. You need libraries or other programs to do it for you. CSV and TXT can be parsed but XLS or XLSX are in a different format – Forbs Mar 22 '17 at 19:27
  • That gibberish looks like an xlsx file, which is a zipped collection of xml files.... good luck writing a parser yourself, it's taken me over 14 years of work now to write PHP parsers for most spreadsheet formats – Mark Baker Mar 22 '17 at 19:30
  • @Forbs why is it not parsable without third party libraries? – ThatsAudio Mar 22 '17 at 19:31
  • @ThatsAudio - It is parsable, it just requires many man-years of code writing for you to develop a parser yourself.... how many years do you have for this project? – Mark Baker Mar 22 '17 at 19:32
  • It's written in a binary format (I believe) instead of an ascii format. Google *simplexlsx* for a library that can convert them in php real time. – Forbs Mar 22 '17 at 19:32
  • Possible duplicate of [Reading an Excel file in PHP](http://stackoverflow.com/questions/563670/reading-an-excel-file-in-php) – csirmazbendeguz Mar 22 '17 at 19:33
  • 1
    [There's comprehensive list of Excel reader/writer libraries for PHP here](http://stackoverflow.com/questions/3930975/alternative-for-php-excel) – Mark Baker Mar 22 '17 at 19:37
  • I believe that @ThatsAudio wanted to do with without libraries so I answered with that's they need a library. Not quite a duplicate, though the answer I provided probably does cross over. – Forbs Mar 22 '17 at 19:48
  • I indeed wanted to do it without libraries. @csirmazbendeguz i do not think you read it through correctly. – ThatsAudio Mar 22 '17 at 20:04
  • @ThatsAudio I do not think you read it through correctly. You can write a parser yourself, but it'll require years of work if you want to support all possible features. Even parsing a CSV file is not easy - just you think about escaping invalid characters like commas itself.. Writing an XLS parsers seems out of scope for a school project. – ventiseis Mar 22 '17 at 20:35
  • @ventiseis yes i did see this, but he was saying that it was a duplicate. – ThatsAudio Mar 23 '17 at 08:07

0 Answers0