Skip to content

xlsx: workbooks with an Excel 4.0 macro sheet fail to open #802

Open

Description

@NazarKalytiuk

Opening an .xlsm that contains an Excel 4.0 macro sheet fails with

Unrecognized sheet:type: xl/macrosheets/sheet1.xml

so none of the workbook's worksheets can be read either.

Xlsx::read_workbook maps the last segment of each sheet's relationship type and accepts only worksheet, chartsheet, and dialogsheet. A macro sheet is related with http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet, and an international macro sheet with http://schemas.microsoft.com/office/2006/relationships/xlIntlMacrosheet. SheetType::MacroSheet already exists, so both could map to it and show up in sheets_metadata() like chart and dialog sheets do.

Reproduced with 0.38.0 and master (27b2458). A minimal package with one worksheet and one macro sheet is enough. Its main part uses the application/vnd.ms-excel.sheet.macroEnabled.main+xml content type, and the macro sheet has an application/vnd.ms-excel.macrosheet+xml override. These are the relevant parts:

xl/workbook.xml:

<sheets>
  <sheet name="Data" sheetId="1" r:id="rId1"/>
  <sheet name="Macro1" sheetId="2" r:id="rId2"/>
</sheets>

xl/_rels/workbook.xml.rels:

<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>
<Relationship Id="rId2" Type="http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet" Target="macrosheets/sheet1.xml"/>

xl/macrosheets/sheet1.xml:

<xm:macrosheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
               xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
  <dimension ref="A1:A2"/>
  <sheetData>
    <row r="1"><c r="A1" t="b"><f>ECHO(FALSE)</f><v>1</v></c></row>
    <row r="2"><c r="A2" t="b"><f>RETURN()</f><v>1</v></c></row>
  </sheetData>
</xm:macrosheet>

I built the repro from these parts by hand because I don't have Excel available, and I can attach that .xlsm. An Excel-saved workbook (Insert > MS Excel 4.0 Macro) would make a better test file.

Activity

  1. Alex-ley-scrub commented on Nov 14, 2026

    @Alex-ley-scrub
    Contributor

    I made a test file with Excel for Mac (16.115): a Data worksheet, an Excel 4.0 macro sheet Macro1 (=ECHO(FALSE), =RETURN()) and an international macro sheet Intl1 (=RETURN()). It's saved as .xlsm, .xlsb and .xls: macro_sheet.zip

    On master (27b2458):

    • .xlsm: Unrecognized sheet:type: xl/macrosheets/sheet1.xml
    • .xlsb fails the same way: Unrecognized BoundSheet8:dt: xl/macrosheets/sheet1.bin. Xlsb::new only accepts sheet paths under worksheets, chartsheets and dialogsheets.
    • .xls already works. Macro1 and Intl1 are SheetType::MacroSheet, and their cells and formulas read correctly.

    Mapping xlMacrosheet and xlIntlMacrosheet (xlsx) and the macrosheets path (xlsb) to SheetType::MacroSheet is enough. With that change, the .xlsm and .xlsb give the same sheets, values and formulas as the .xls. Excel saves both kinds of macro sheet under xl/macrosheets/ (sheet1.xml and intlsheet1.xml). Feel free to use these files as the test file.

  2. NazarKalytiuk commented on Nov 15, 2026

    @NazarKalytiuk
    Author

    Thanks for the files and the analysis. I opened #803 with that change for xlsx and xlsb. It uses your three files, unedited, as tests/macro_sheets.{xlsm,xlsb,xls}, and checks that each format gives the same sheets, values and formulas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions