wordpress hit counter
Excel 2007 complains about malformed xl/worksheets/sheet.xml and renders incorrectly. - SpreadsheetML - Formats - OpenXML Developer

Excel 2007 complains about malformed xl/worksheets/sheet.xml and renders incorrectly.

Formats

Discussions about working with different Open XML Formats

Excel 2007 complains about malformed xl/worksheets/sheet.xml and renders incorrectly.

  • rated by 0 users
  • This post has 2 Replies |
  • 1 Follower
  • I am trying to generate an Excel spreadsheet programmatically and have been running into issues while trying to open the file in Excel. I get an error saying that the xl/worksheets/sheet1.xml is malformed and that Excel will correct is it. After correction the spreadsheet is displayed but will poor styling. Below is the XML generated from the code.

     

    [Content_Types]

     

      <?xml version="1.0" encoding="utf-8" ?>
    - <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
      <Default Extension="xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />
      <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
      <Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />
      <Override PartName="/xl/worksheets/sheet.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />
      </Types>

    _rels folder

    <?xml version="1.0" encoding="utf-8" ?>
    - <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
      <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="/xl/workbook.xml" Id="R0152eddce21d41df" />
      </Relationships>
    xl  - folder
        _rels folder - Workbook.xml
     
       
    <?xml version="1.0" encoding="utf-8" ?>
    - <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
      <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="/xl/styles.xml" Id="Rcd66b481d7514fed" />
      <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="/xl/worksheets/sheet.xml" Id="R48dec88cc4b54347" />
      </Relationships>

      worksheets folder

     

      sheet.xml - file

     

    <?xml version="1.0" encoding="utf-8" ?>
    - <x:worksheet xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
    - <x:sheetData>
    - <x:row r="1">
    - <x:c r="A1" s="0">
      <x:v>Black Farmers Discrimination Litigation</x:v>
      </x:c>
      <x:c r="B1" />
      <x:c r="C1" />
      <x:c r="D1" />
      <x:c r="E1" />
      </x:row>
    - <x:row r="2">
    - <x:c r="A2" s="0">
      <x:v>Communication Summary: All Activity By Month</x:v>
      </x:c>
      <x:c r="B2" />
      <x:c r="C2" />
      <x:c r="D2" />
      <x:c r="E2" />
      </x:row>
    - <x:row r="3">
    - <x:c r="A3" s="2">
      <x:v>one</x:v>
      </x:c>
    - <x:c r="B3" s="2">
      <x:v>two</x:v>
      </x:c>
    - <x:c r="C3" s="2">
      <x:v>three</x:v>
      </x:c>
    - <x:c r="D3" s="2">
      <x:v>four</x:v>
      </x:c>
    - <x:c r="E3" s="2">
      <x:v>five</x:v>
      </x:c>
      </x:row>
      </x:sheetData>
    - <x:mergeCells count="2">
      <x:mergeCell ref="A1:B1:C1:D1:E1" />
      <x:mergeCell ref="A2:B2:C2:D2:E2" />
      </x:mergeCells>
      </x:worksheet>
    xl folder - styles.xml
    <?xml version="1.0" encoding="utf-8" ?>
    - <x:styleSheet xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
    - <x:fonts count="7">
      <x:font />
      <x:font />
    - <x:font>
      <x:sz val="12" />
      <x:color rgb="00000000" />
      <x:name val="Times New Roman" />
      </x:font>
    - <x:font>
      <x:b />
      <x:sz val="10" />
      <x:color rgb="00FFFFFF" />
      <x:name val="Times New Roman" />
      </x:font>
    - <x:font>
      <x:b />
      <x:sz val="22" />
      <x:color rgb="00000000" />
      <x:name val="Times New Roman" />
      </x:font>
    - <x:font>
      <x:b />
      <x:sz val="16" />
      <x:color rgb="00000000" />
      <x:name val="Times New Roman" />
      </x:font>
    - <x:font>
      <x:i />
      <x:sz val="10" />
      <x:color rgb="00000000" />
      <x:name val="Calibri" />
      </x:font>
      </x:fonts>
    - <x:fills count="5">
    - <x:fill>
      <x:patternFill patternType="none" />
      </x:fill>
    - <x:fill>
      <x:patternFill patternType="gray125" />
      </x:fill>
    - <x:fill>
    - <x:patternFill patternType="solid">
      <x:bgColor rgb="F0F8FF00" />
      </x:patternFill>
      </x:fill>
    - <x:fill>
    - <x:patternFill patternType="solid">
      <x:bgColor rgb="C0C0C000" />
      </x:patternFill>
      </x:fill>
    - <x:fill>
    - <x:patternFill patternType="solid">
      <x:fgColor rgb="00000000" />
      </x:patternFill>
      </x:fill>
      </x:fills>
    - <x:borders count="2">
      <x:border />
    - <x:border>
    - <x:top style="thin">
      <x:color rgb="00000000" />
      </x:top>
    - <x:bottom style="thin">
      <x:color rgb="00000000" />
      </x:bottom>
      </x:border>
      </x:borders>
    - <x:cellXfs count="6">
    - <x:xf fontId="4" fillId="0" borderId="1" applyFill="1" applyBorder="0" applyAlignment="1">
      <x:alignment horizontal="center" vertical="center" />
      </x:xf>
    - <x:xf fontId="5" fillId="0" borderId="0" applyFill="0" applyBorder="0" applyAlignment="1">
      <x:alignment horizontal="center" vertical="center" />
      </x:xf>
    - <x:xf fontId="2" fillId="1" borderId="0" applyFill="0" applyBorder="0" applyAlignment="1">
      <x:alignment horizontal="center" vertical="center" />
      </x:xf>
    - <x:xf fontId="3" fillId="0" borderId="1" applyFill="1" applyBorder="1" applyAlignment="1">
      <x:alignment horizontal="center" vertical="center" />
      </x:xf>
    - <x:xf fontId="6" fillId="1" borderId="1" applyFill="1" applyBorder="1" applyAlignment="1">
      <x:alignment horizontal="center" vertical="center" />
      </x:xf>
    - <x:xf fontId="2" fillId="1" borderId="0" applyFill="0" applyBorder="0" applyAlignment="1">
      <x:alignment horizontal="center" vertical="center" />
      </x:xf>
      </x:cellXfs>
    - <x:cellStyles count="1">
      <x:cellStyle name="Normal" xfId="0" builtinId="0" />
      </x:cellStyles>
      <x:dxfs count="0" />
      <x:tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleLight16" />
      </x:styleSheet>

    xl folder - workbook.xml

    <?xml version="1.0" encoding="utf-8" ?>
    - <x:workbook xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
    - <x:sheets>
      <x:sheet name="Communication Report" sheetId="1" r:id="R48dec88cc4b54347" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" />
      </x:sheets>
      </x:workbook>

    Does anyone see any issues here. I know its quite a bit of XML. I would appreciate any help I can get.

     

    Thank  you.

  • Hi,

    These types of issues can indeed be a bit tough to sort out. Two approachs that I've used successfully in the past are:

    • After you have generated a spreadsheet that Excel will not open, save away a copy, then let Excel open and fix, and then compare the saved copy to the copy that was fixed by Excel, to see what markup you are writing that is incorrect.
    • Use a binary search approach - simplify your generation program until it generates a spreadsheet that opens successfully. Then add in feature by feature until Excel will not open it. You can then more easily debug the issue.

    -Eric

  • By the way, one small thing you can do to make it easier to work with code listings here in the forums on OpenXMLDeveloper.org: use the Insert Code { } button on the toolbar in the rich-text editor. That will make it easier to copy out the XML, look at it, debug it, and etc.

    -Eric

Page 1 of 1 (3 items)