Uncaught InterfaceHdr codePage 1252 #209

Closed
opened 2015-04-16 08:45:52 +00:00 by Batistleman · 8 comments
Batistleman commented 2015-04-16 08:45:52 +00:00 (Migrated from github.com)

I get this weird error when testing with a specific xls file.

Uncaught InterfaceHdr codePage 1252

I would guess this is a pretty standard code page no?

However, I don't understand why this check is present? Am I missing something? Should I do a conversion first?

function parse_InterfaceHdr(blob, length) {
    if(length === 0) return 0x04b0;
    var q;
    if((q=blob.read_shift(2))!==0x04b0) throw 'InterfaceHdr codePage ' + q;
    return 0x04b0;
}
I get this weird error when testing with a specific xls file. ``` Uncaught InterfaceHdr codePage 1252 ``` I would guess this is a pretty standard code page no? However, I don't understand why this check is present? Am I missing something? Should I do a conversion first? ``` function parse_InterfaceHdr(blob, length) { if(length === 0) return 0x04b0; var q; if((q=blob.read_shift(2))!==0x04b0) throw 'InterfaceHdr codePage ' + q; return 0x04b0; } ```
SheetJSDev commented 2015-04-16 13:45:42 +00:00 (Migrated from github.com)

In general, if there's any confusion, look in the general area of the related code block for a guide comment. In this case, there's a comment just above that code block:

/* 2.4.146 */

Every bare reference points to some spec in the References section of the README. The default for XLS-related references is "[MS-XLS]: Excel Binary File Format (.xls) Structure Specification".

The comment references section 2.4.146 of [MS-XLS], which strongly suggests that only code page 1200 (UTF16LE) is permitted:

codePage (2 bytes): An unsigned integer that specifies the code page.

MUST be 0x04B0, which specifies Unicode.

Interestingly enough, the record definition in [XLS] differs:

Code page the file is saved in:
01B5h (437 dec.) = IBM PC (Multiplan)
8000h (32768 dec.) = Apple Macintosh
04E4h (1252 dec.) = ANSI (Microsoft Windows)

Can you possibly share a file that triggers the error? It's weird because the spec suggests it should only happen in Excel 97+ (BIFF8):

In BIFF7 and earlier, it has no record data field.

In general, if there's any confusion, look in the general area of the related code block for a guide comment. In this case, there's a comment just above that code block: ``` /* 2.4.146 */ ``` Every bare reference points to some spec in [the References section of the README](https://github.com/SheetJS/js-xlsx#references). The default for XLS-related references is "[MS-XLS]: Excel Binary File Format (.xls) Structure Specification". The comment references section [2.4.146 of [MS-XLS]](https://msdn.microsoft.com/en-us/library/dd945324.aspx), which strongly suggests that only code page 1200 (UTF16LE) is permitted: > **codePage (2 bytes):** An unsigned integer that specifies the code page. > > MUST be 0x04B0, which specifies Unicode. Interestingly enough, the record definition in [[XLS]](http://www.digitalpreservation.gov/formats/digformatspecs/Excel97-2007BinaryFileFormat%28xls%29Specification.pdf) differs: > Code page the file is saved in: > 01B5h (437 dec.) = IBM PC (Multiplan) > 8000h (32768 dec.) = Apple Macintosh > 04E4h (1252 dec.) = ANSI (Microsoft Windows) Can you possibly share a file that triggers the error? It's weird because the spec suggests it should only happen in Excel 97+ (BIFF8): > In BIFF7 and earlier, it has no record data field.
Batistleman commented 2015-04-16 18:56:31 +00:00 (Migrated from github.com)

The weird thing is, as soon as I open the file and save it again I see the file size going in half. (It's a file I got from a friend an contains some sensitive data, can mail it?)

The weird thing is, as soon as I open the file and save it again I see the file size going in half. (It's a file I got from a friend an contains some sensitive data, can mail it?)
SheetJSDev commented 2015-04-16 19:07:17 +00:00 (Migrated from github.com)

@Batistleman it's possible your friend used a tool that wasn't excel. Many third-party writers have strange quirks.

Shoot me an email at dev at sheetjs.com (this is the email address used for git commits)

@Batistleman it's possible your friend used a tool that wasn't excel. Many third-party writers have strange quirks. Shoot me an email at dev at sheetjs.com (this is the email address used for git commits)
SheetJSDev commented 2017-03-28 23:39:28 +00:00 (Migrated from github.com)

I cannot find a file in the wild to reproduce this issue, nevertheless we will remove the error message and just ignore the field entirely.

I cannot find a file in the wild to reproduce this issue, nevertheless we will remove the error message and just ignore the field entirely.
leonardodelfino commented 2017-04-05 18:52:14 +00:00 (Migrated from github.com)

I am having the same problem in reading a file, do you have any solution for this case?

I am having the same problem in reading a file, do you have any solution for this case?
SheetJSDev commented 2017-04-05 19:38:47 +00:00 (Migrated from github.com)

@leonardodelfino can you share a file? The only sort of files we could "find" are ones that we manually created by hex-editing good files, so it would be of interest to see a file

@leonardodelfino can you share a file? The only sort of files we could "find" are ones that we manually created by hex-editing good files, so it would be of interest to see a file
leonardodelfino commented 2017-04-06 11:05:18 +00:00 (Migrated from github.com)

I am sharing the file with problem, I had to delete some lines because this file has confidential information of a client of mine. However I did some tests and even after editing the file still fails to read.

Sheet example.xls.zip

Thanks for you support!

I am sharing the file with problem, I had to delete some lines because this file has confidential information of a client of mine. However I did some tests and even after editing the file still fails to read. [Sheet example.xls.zip](https://github.com/SheetJS/js-xlsx/files/902321/Sheet.example.xls.zip) Thanks for you support!
SheetJSDev commented 2017-04-06 14:33:19 +00:00 (Migrated from github.com)

@leonardodelfino can you check against http://oss.sheetjs.com/js-xlsx/ (just drag and drop the file there) -- you might be using a older version

@leonardodelfino can you check against http://oss.sheetjs.com/js-xlsx/ (just drag and drop the file there) -- you might be using a older version
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#209
No description provided.