none
Missed or corrupted PALETTE record in xls file RRS feed

  • Question

  •  Hi, 

    I'm sorry, my account isn't verified yet and I can't add link to file.

    I create file with Excel 2016, fill A1:B2 cells with light-green color: rgb(198,224,180) and save file as xls (Excel 1997-2003).

    When I'm trying to read this file using Libre Office the actual color is light-yellow: rgb(255,255,153), and it differs from the expected one.

    A tried to debug this issue (using NPOI library) and found out that for some reason there's no PALETTE record in binary stream (or maybe it's corrupted), result color has index 43 and light-yellow color has this index in the default palette. But along with it Excel correctly shows this color so i suppose that information about custom palette still can be retrieved somehow. So my question is how to retrieve this information and why this issue could happen.

    Thanks, Gregor


    Monday, March 25, 2019 2:14 PM

Answers

  • The color should be found in the XFExt records that map the XF records (when they specify the fHasXfExt flag as 1. [MS-XLS] 2.4.355 XFExt details these records. The XFExt for a cell with a solid fill (the CellXF.fls field is 1 as described in 2.5.20 CellXF) has the foreground set to the background color. 

    Tom

    Wednesday, March 27, 2019 11:46 PM
    Moderator

All replies

  • Hi Gregor,

    Thank you for this question. One of our engineers will review this and follow-up soon.

    Thanks,

    Edgar

    Monday, March 25, 2019 3:20 PM
    Moderator
  • Hi Gregor, 

    Thanks for the question, I will look into this. I looks like I should be able to reproduce this behavior by following your steps and no sample file will be needed from you, correct? 

    Also, just a question: are you implementing Libre Office? We typically work with the implementers of the consumers/producers of the file format in order to interoperate with Microsoft Office. 

    Best regards,
    Tom Jebo
    Sr Escalation Engineer
    Microsoft Open Specifications

    Monday, March 25, 2019 6:12 PM
    Moderator
  • Hi Tom,

    Thank you for your reply!

    Yes, I think it should be easily reproduced without file, but I'll attach it as soon as I can

    I'm implementing .NET library for working with Excel formats and currently I'm trying to understand whether the problem is inside my code or it's the issue with xls format. So I've tried to open this file in Libre Office and got the same result. For now I believe that the issue is not on my side, though another options is that both Libre Office and my library work incorrectly.

    NOTE: Excel 2003 also shows light-yellow color, I think it's somehow connected with compatibility mode.

    Thanks, Gregor


    Tuesday, March 26, 2019 9:49 AM
  • Thanks for the explanation Gregor. I think then I should be able to reproduce this. I'll let you know if I can't. 

    Tom

    Tuesday, March 26, 2019 4:59 PM
    Moderator
  • I've tested this also and if you turn on the compatibility checker, you'll see that setting a cell fill color to light green (146, 208, 80) causes Excel 2016 to flag the color (cell style) as unsupported and convert it to a close color in the default palette, light yellow (255, 255, 153). It does this when saving in Excel 97-2003 .xls format and yes, compatibility mode is on. So this is to be expected and the user is warned of the compatibility change.

    In [MS-XLS] 2.5.161 "Icv", the specification does state that if no PALETTE record exists in the file (i.e. in the Globals Stream), then the default palette is used and those values are listed in this section. 

    Hope this helps,

    Tom

    Wednesday, March 27, 2019 12:18 AM
    Moderator
  • Hi Tom

    Thank you for your reply, now this behavior is clear for me.

    If I open this converted xls file in Excel 2016, I'll see light-green color as expected and therefore I suppose that information about this custom color isn't lost after conversion and it's still somehow stored in this file (as I understood it's just flagged as unsupported). My question is are there any possibilities to retrieve this color despite the lack of PALETTE record. Also please correct me if I'm wrong.

    Thanks a lot for your help,

    Gregor

    Wednesday, March 27, 2019 10:00 AM
  • The color should be found in the XFExt records that map the XF records (when they specify the fHasXfExt flag as 1. [MS-XLS] 2.4.355 XFExt details these records. The XFExt for a cell with a solid fill (the CellXF.fls field is 1 as described in 2.5.20 CellXF) has the foreground set to the background color. 

    Tom

    Wednesday, March 27, 2019 11:46 PM
    Moderator
  • Thanks a lot for your help!
    Friday, March 29, 2019 7:26 AM