Objective
Because of the need to directly read the Excel file data, but search on the internet many times did not find a good way,
Usually read through ODBC or OLE, but both of these methods have limitations ... (I believe we all know it).
What do we do? No way, have to choose the most difficult way--analysis of Excel file format.
Introduced
MS Excel is well known for spreadsheet processing software. The Excel file format is a specific Biff (Binary Interchange File format), where many records are stored in Biff, and the record header and the record body are included in the section. The record header is 4byte, the first two digits specify the record type code (opcode), the last two digits specify the record length, and the record body is the actual data that stores the record.
Like what:
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 |
记录头:
opcode: 09h is BOF;
length: 04h record body is 4 bytes long;
记录体:
version number:02h is version number (2 for the initial version of Excel)
file type:10h is a worksheet file;
具体可参考MS Excel File Format。
Describe