【问题标题】:Transformation from XML to Excel 2010 file从 XML 转换为 Excel 2010 文件
【发布时间】:2014-01-21 16:34:29
【问题描述】:

如何为从 XML 文件到 Excel 2010 文件或 Word 2010 的 XSLT 转换创建模板?

这是我们在 Execel 2003 中的转换模板。但现在我需要它来 2010 年吗? 感谢您的帮助!

    <xsl:stylesheet xmlns="urn:schemas-microsoft-com:office:spreadsheet"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xslex="urn:XsltExtension"
                xmlns:html="http://www.w3.org/TR/REC-html40"
                xmlns:o="urn:schemas-microsoft-com:office:office"
                xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
                xmlns:x="urn:schemas-microsoft-com:office:excel"
                version="2.0">
  <xsl:output method="xml" indent="yes" />
   <xsl:output method="xml" version="1.0"/>
   <xsl:template match="/NewDataSet">
      <xsl:variable name="elements"          select="xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence/*" />

      <xsl:variable name="columnAppearances" select="ColumnAppearances/*" />

      <xsl:processing-instruction name="mso-application">
         <xsl:text>progid="Excel.Sheet"</xsl:text>
      </xsl:processing-instruction>
      <Workbook>
     <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office" />
     <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
        <ProtectStructure>False</ProtectStructure>
        <ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
    </xsl:styleshee>

【问题讨论】:

标签: c# xml excel xslt ms-word


【解决方案1】:

Excel 2007+ 使用的开放 XML 格式由 ZIP 包内的许多 XML 组成。整体格式与您提到的单文件 XML 格式非常不同。如果您现在有一个可行的解决方案,我建议您保持原样,并使用互操作将其转换为更新的格式。如果您想避免互操作,那么您应该改用 OpenXML SDK。使用 XSLT 做这件事会非常痛苦,如果不是不可能的话,而且这里肯定是题外话,因为这是大量的工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多