Repaired Records : Cell information from worksheet created from scratch

前端 未结 7 1486
醉话见心
醉话见心 2021-01-31 08:58

I\'m receiving an error when opening my OpenXML created spreadsheet. The error is as follows.

Repaired Records: Cell information from /xl/worksheets/sheet.xml p         


        
相关标签:
7条回答
  • 2021-01-31 09:29

    If you are adding a string to a cell rather than a number (or a string that can be converted to a number) then you should use an inline string or a shared string instead of the CellValue. You can only use CellValue if the value is numeric.

    The XML generated when using CellValue looks something like:

    <x:row>
      <x:c>
        <x:v>12345</x:v>
      </x:c>
    </x:row>
    

    when you use an inline string it looks like:

    <x:row>
      <x:c t="inlineStr">
        <x:is>
          <x:t>Foo</x:t>
        </x:is>
      </x:c>
    </x:row>
    

    note the "is" node for inline string and that the cell type attribute is set to "inlineStr".

    Here is C# code to generate correct XML for a cell containing text:

    cell.DataType = CellValues.InlineString;
    cell.InlineString = new InlineString() { Text = new Text(textToInsert) };
    

    From what I have read using shared strings is preferable but using inline strings avoids the error and looks just fine when you open the file in Excel.

    0 讨论(0)
提交回复
热议问题