各位大虾,小弟在做个东西,要到处xml格式的excel,本来内容里面没有中文的话打开时没问题的,但是发现里面一旦包含中文就有问题了,不知道大虾大牛们有没有什么办法可以解决这个问题,小弟感激不敬。其他的地方有中文可以,就红色的那里如果有中文就打开不了了,我觉得应该不是编码的问题,可能是有哪个编码属性要设置一下的,但是没搞过这个东西,不知道在哪里设置。<?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">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  <Title>Excel表格</Title>
  <LastAuthor>bigtall</LastAuthor>
</DocumentProperties>
<Styles>
  <Style ss:ID="Default" ss:Name="Normal">
   <Alignment ss:Vertical="Center"/>
   <Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>
  </Style>
</Styles>
<Worksheet ss:Name="tt">
  <Table>
   <Row>
    <Cell ss:MergeAcross="6" ><Data ss:Type="String">Hello! 大哥</Data></Cell>
   </Row>
  </Table>
</Worksheet>
</Workbook>

解决方案 »

  1.   

    不能预览,发现发出来之后代码那里有问题,代码里面是不能加格式的,所以多了个color标签,正确的代码是这个。多了那个“大哥”就不行了。
    <?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">
    <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
      <Title>Excel表格</Title>
      <LastAuthor>bigtall</LastAuthor>
    </DocumentProperties>
    <Styles>
      <Style ss:ID="Default" ss:Name="Normal">
       <Alignment ss:Vertical="Center"/>
       <Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>
      </Style>
    </Styles>
    <Worksheet ss:Name="tt">
      <Table>
       <Row>
        <Cell ss:MergeAcross="6" ><Data ss:Type="String">Hello! 大哥</Data></Cell>
       </Row>
      </Table>
    </Worksheet>
    </Workbook>