创建xml文档时,Excel无法识别换行符

时间:2015-04-22 23:39:09

标签: xml excel line-breaks

我尝试在MUMPS中编写XML代码,以便在Excel中使用。这是我的MUMPS代码:

s incResStr=incResStr_[newData]+"
"

基本上将数据连接成一个字符串,并在每个新片段之间添加换行符。问题是,当我在Notepad ++中打开它时,XML看起来像这样:

<ss:Cell ss:StyleID="base">
        <ss:Data ss:Type="String">^^^^^3^ &amp;#10; ^^^^^2521^ &amp;#10; ^^^^^2515^ &amp;#10; ^^^^^107^ &amp;#10; </ss:Data>

注意&#39;&#39;&#39;这意味着它实际上正在转换我的&amp;进入&amp;的实际实体。然后它没有认识到#10;任何有用的东西。关于如何阻止它这样做的任何想法?

1 个答案:

答案 0 :(得分:1)

Without some code such questions are really vague. And even if you can't use pictures, you could provide some XML code and at least tell us which kind of XML you mean. For this you should create an example with minimal but complete code which shows the problem. Programmers call this a Short, Self Contained, Correct (Compilable), Example http://sscce.org/ or Minimal, Complete, and Verifiable example https://stackoverflow.com/help/mcve.

I suspect you mean SpreadsheetML. Then such a SSCCE could be:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <Styles>
  <Style ss:ID="wrapText">
   <Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
  </Style>
 </Styles>
 <Worksheet ss:Name="Tabelle1">
  <Table>
   <Row>
    <Cell><Data ss:Type="String">Text with linebreaks</Data></Cell>
   </Row>
   <Row ss:Height="60">
    <Cell ss:StyleID="wrapText"><Data ss:Type="String">This&#10;is&#10;a&#10;test</Data></Cell>
   </Row>
  </Table>
 </Worksheet>
</Workbook>

Note: I have provided a Style element for wrap text and applied this to the Cell with the multiline text.