MS-XLSB clarification: record type 3072 (0x0C00) and PtgAttrIfError byte-offset calculation

Jasuja, Om 0 Reputation points
2026-11-03T12:52:28.4033333+00:00

Hello,

I am implementing a read-only comparator for Excel binary (.xlsb) files and would appreciate clarification on two points in the MS-XLSB specification.

  1. Record type 3072 (0x0C00)

Does decoded record type value 3072 (0x0C00) identify BrtUid?

If so, could you point me to the authoritative record-type mapping, structure definition, and applicable version information? Please also clarify any requirements for preserving this record when copying worksheet content.

  1. PtgAttrIfError byte-offset calculation

The PtgAttrIfError structure defines its offset field as an unsigned integer specifying a byte offset.

Could you clarify:

  • The exact starting point from which the offset is measured.
  • The target location the offset must identify.
  • Which token bytes are included or excluded from the calculation.

A minimal worked example showing the formula token sequence, token lengths, and resulting offset would be very helpful.

This request concerns interpretation of the public MS-XLSB specification only. No workbook or business data is attached.

Thank you.

Microsoft 365 and Office | Excel | For home | Other

2 answers

Sort by: Most helpful
  1. Kai-H 30,315 Reputation points Microsoft External Staff Moderator
    2026-11-04T10:39:38.3666667+00:00

    Hi, Jasuja, Om

    I can help with both points, though the record mapping has a gap I can't close from public sources.

    Record 3072. I couldn't find a published record-number table entry that ties 3072 to BrtUid. The BrtUid page (section 2.4.857) only defines the payload, a 16-byte GUID whose meaning depends on the record sequence it's in, and it gives no type value or version note. Mapping 3072 to BrtUid is a common convention in open-source XLSB parsers, not something the spec states. The SheetJS project ran into this same "unexpected record 3072" case back in 2018. They treated it as BrtUid as a best guess and flagged the missing table entry as a spec gap. For a read-only comparator, it is recommended that you treat 3072 as "probably BrtUid," show it as an opaque GUID, and not flag GUID-only differences as content changes. If you need an official ruling, you can contact the Open Specifications support team through the Support section of the Open Specifications Dev Center on Learn. Mention section 2.3 (Record Enumeration) and section 2.4.857. That team handles spec corrections and can confirm or add the entry.

    PtgAttrIfError offset. I couldn't find any documented version-specific exception or alternative encoding where the offset is 3. Both the PtgAttrIfError and PtgAttrIf pages only say the offset is an unsigned byte offset. The actual rules are in the Rgce grammar (section 2.5.98.88), which measures offsets as EXPRESSION_SIZE.

    The 7-byte reading also follows from how the jump works. When the first expression isn't an error, the evaluator skips past the fallback and the GoTo token, so it lands right on the IFERROR function token. With an offset of 3, it would land on the GoTo instead, and the GoTo would then jump past the function token. In that case IFERROR would never run.

    Here's a quick way to check with a real file. Save =IFERROR(A1,0) as .xlsb and look at the formula bytes. You should see the A1 reference (7 bytes), then PtgAttrIfError (4 bytes, offset 7), then the integer 0 (3 bytes), then PtgAttrGoTo (4 bytes, offset 2), and finally the IFERROR PtgFunc (3 bytes, function number 480). That gives 3 + 4 = 7 for the PtgAttrIfError offset, and 3 - 1 = 2 for the GoTo.

    Was this answer helpful?


  2. AI answer

    2026-11-03T12:53:43.8066667+00:00

    The specification confirms that BrtUid contains a 16-byte GUID, but the supplied authoritative sections do not establish that decoded record type 3072 (0x0C00) maps to BrtUid; that mapping should therefore not be implemented without checking the record-number table in the applicable MS-XLSB revision.

    BrtUid

    MS-XLSB section 2.4.857 defines BrtUid as follows:

    • It specifies a unique identifier for an object.
    • Its payload is exactly one 16-byte uid GUID.
    • The object being identified is determined by the record sequence containing the record—not by BrtUid alone.^1^

    The section number 2.4.857 is a document section number, not a record-type value. Nothing in the available authoritative material provides the normative record-type-table entry connecting BrtUid to 0x0C00. Also verify that 3072 is the value produced after decoding the XLSB variable-length record-type field, rather than a raw two-byte little-endian interpretation.

    For a comparator, keep these concepts separate:

    record type: decoded from the record header
    record size: decoded from the record header
    record data: for BrtUid, 16-byte GUID
    meaning: determined by the enclosing record sequence
    

    Version and preservation

    The current BrtUid page does not include a product-version note in the supplied text, so it is not sufficient to claim which Excel release first introduced that record. XLSB itself dates from Excel 2007, but that does not prove that every record in the current specification applies to every XLSB-producing version.^2^

    No BrtUid-specific copying rule is present in the supplied MS-XLSB sections. Consequently:

    • A read-only comparator can compare the 16 payload bytes and report the containing record sequence.
    • Do not treat two differing UIDs as proof that the identified worksheet content differs semantically.
    • Do not claim a normative requirement either to preserve or regenerate the UID without the applicable enclosing record-sequence rule.
    • If performing a byte-preserving transformation rather than using Excel’s object model, retaining an unmodified, understood record is the conservative implementation choice, but that is not established here as an MS-XLSB requirement.

    PtgAttrIfError.offset

    PtgAttrIfError is a four-byte control token:

    Component Size
    ptg plus reserved1 1 byte
    reserved2 plus bitIfError 1 byte
    offset 2 bytes
    Total 4 bytes

    Its ptg value must be 0x19, bitIfError must be 1, and offset is an unsigned two-byte integer.^3^

    The governing Rgce grammar is:

    iferror-expression =
        expression
        PtgAttrIfError
        expression
        PtgAttrGoTo
        PtgFunc
    

    The offset equals the total encoded size, in bytes, of every Ptg after PtgAttrIfError through and including the first PtgAttrGoTo.^4^

    Therefore:

    • Starting boundary: immediately after the complete four-byte PtgAttrIfError.
    • Target boundary: immediately after the first following PtgAttrGoTo.
    • Excluded: all bytes of PtgAttrIfError, the expression before it, and the trailing PtgFunc.
    • Included: every byte of the fallback expression following PtgAttrIfError, plus every byte of the first PtgAttrGoTo.
    • Count complete serialized Ptg structures, including their opcode and fields—not merely operand data.

    Worked offset calculation

    Assume the parser measures this serialized token stream:

    Token Encoded size Running position
    First expression 5 0–4
    PtgAttrIfError 4 5–8
    Fallback expression 3 9–11
    First PtgAttrGoTo 4 12–15
    PtgFunc(IFERROR) N 16 onward

    Then:

    PtgAttrIfError.offset
        = size(fallback expression) + size(first PtgAttrGoTo)
        = 3 + 4
        = 7 bytes
    

    Equivalently, using zero-based stream positions:

    offset = position immediately after PtgAttrGoTo
           - position immediately after PtgAttrIfError
           = 16 - 9
           = 7
    

    The final PtgFunc is excluded. Its iftab must be 0x01E0, identifying IFERROR. Separately, the PtgAttrGoTo.offset equals one less than the encoded size of that trailing PtgFunc.^4^

    These conditional control tokens prescribe short-circuit evaluation and may be ignored only when converting the parsed expression to textual formula syntax—not when validating or reproducing the binary token stream.^5^


    References

    1. [MS-XLSB]: BrtUid | Microsoft Learn
    2. Excel performance: Tips for optimizing performance obstructions
    3. [MS-XLSB]: PtgAttrIfError | Microsoft Learn
    4. [MS-XLSB]: Rgce | Microsoft Learn
    5. [MS-XLSB]: Control Tokens | Microsoft Learn
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.