I currently have a method that receives a byte array of an excel file. It worked great, and I had it differentiating the file types (.xls
, and .xlsx
) based on the first two bytes in the file. If it's an .xlsx
it started with a PK. Unfortunately, now I am getting .xlsm
files sent, and I don't know what byte differs to tell them apart. I don't have the filename at this point to get the extension.
views:
20answers:
1
+1
A:
The only difference between .xlsx and .xlsm is that the latter may include Macros. I'm quite sure you need further parsing of the file to find that out.
Note that the magic number "PK" (actually it is PK\x03\x04) in the beginning of the .xlsx refers to ZIP compressed data. To further parse the file, you first have to decode (uncompress) it according to ZIP file format.
ypnos
2010-08-30 15:04:53
Thanks, I'll just add a method that also takes the file extension as a parameter. Save me the headache of trying to figure it out. Sucks that excel relies on that extension being correct all the time
Chad
2010-08-30 15:37:10
'sucks' and 'excel' in one sentence.. looks familiar to me :D
ypnos
2010-08-30 20:00:00