验证Excel是否为BIFF8格式 [英] Verify if the excel is BIFF8 format

查看:321
本文介绍了验证Excel是否为BIFF8格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以让我知道我们如何验证Excel是否为BIFF8格式(对于xls和xlsx都适用)

Can anyone let me know how we can verify if the excel is BIFF8 format (Both for xls and xlsx)

推荐答案

嗯,对于晚于97的Excel文件它似乎是默认值:
无需使用Microsoft Excel即可生成Excel文件 [ ^ ]

但我认为它在2007年再次发生了变化:
http://en.wikipedia.org/wiki/Microsoft_Excel [
Well, for Excel files later than 97 it seems to be default:
Generate Excel files without using Microsoft Excel[^]

But I think it got changed again in 2007:
http://en.wikipedia.org/wiki/Microsoft_Excel[^]

xlsx is just a collection of XML files, just change the .xlsx to .zip, unpack it an see for yourself. Completely different from the previous Excel versions. I dont think thouse files use BIFF8 at all...


BOF is at 09h. See table below:

Record Type                Opcode (Hexadecimal)
---------------		------------------------
BOF                           09

I will expplain using MS Specification as :

There are many types of BIFF records.  Each has a 4 byte header.  The
first two bytes are an opcode that specifies the record type.  The second two bytes
specify record length.  Header values are stored in byte-reversed form (less significant
byte first).  The rest of the record is the data itself:

BIFF record header:

                 |  Record Header    |  Record Body
Byte Number    	 |  0    1    2    3 |  0    1   ...
                -----------------------------------
Record Contents	 | XX | XX | XX | XX | XX | XX | ...
                -----------------------------------
                | opcode   | length  | data
				
Each X represents a hexadecimal digit
Two X's form a byte.  The least significant (low) byte of the opcode is byte 0 and the
most significant (high) byte is byte 1.  Similarly, the low byte of the record length
field is byte 2 and the high byte is byte 3

BOF (Beginning of File):
The first record in every spreadsheet is always of the BOF type
BOF record.
           |  Record Header    |    Record Body    |
Byte       |  0    1    2    3 |  0    1    2    3 |
           -----------------------------------------
Contents   | 09 | 00 | 04 | 00 | 02 | 00 | 10 | 00 |
           -----------------------------------------
           | opcode  | length  | version |  file   |
           |         |         |  number |  type   |
The first two bytes, arranged with the low byte first, show that the opcode for BOF is
09h.  The second two bytes indicate that the record body is 4 bytes long.  The first two
bytes of the body are the version number (2 for the initial version of Excel).  The last
two bytes are the file type.  Type 10h is a worksheet file.


这篇关于验证Excel是否为BIFF8格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆