2012-05-09 12 views
0

XMLがあり、Microsoft Office Document(2007)に変換する必要があります。それを行う最善の方法と最速の方法は何ですか?私はC#またはJavaを使用してそれを行うことができます。私はその尖塔を見た。私はそれをすることができますが、それは非常に高価です、代替はありますか? Microsoftは何かを提供していますか?XMLをMS Docに変換するには?

+0

これは本当にXMLの仕組みではありません。 –

+0

どのようなXML文書ですか? – Taymon

+0

そして、どのような "Officeドキュメント"が欲しいですか?スプレッドシート?ワード?パワーポイント? Eメール?注...? –

答えて

4

XSLTを使うことができます。キリスト教のNagelのOneNotesにはhereという素晴らしいサンプルがあります。

<?xml version="1.0" encoding="utf-8" ?> 
    <Courses> 
    <Course Number="MS-2524"> 
     <Title>XML Web Services Programming</Title> 
    </Course> 
    <Course Number="MS-2124"> 
     <Title>C# Programming</Title> 
    </Course> 
    <Course Number="NET2"> 
     <Title>.NET 2.0 Early Adapter</Title> 
    </Course> 
    </Courses> 

そして、このXMLスタイルシート使用して、このXMLを撮る:

<?xml version="1.0" encoding="UTF-8" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"> 
<xsl:output method="xml" indent="yes" /> 
<xsl:template match="/"> 
    <xsl:processing-instruction name="mso-application"> 
    <xsl:text>progid="Word.Document"</xsl:text> 
    </xsl:processing-instruction> 
    <w:wordDocument> 
    <w:body> 
    <xsl:apply-templates select="Courses/Course" /> 
    </w:body> 
    </w:wordDocument> 
</xsl:template> 
<xsl:template match="Course"> 
    <w:p> 
    <w:r> 
     <w:t> 
     <xsl:value-of select="@Number" />, <xsl:value-of select="Title"/> 
     </w:t> 
    </w:r> 
    </w:p> 
</xsl:template> 
</xsl:stylesheet> 

するコードの参照でこれを行うには2003

<?xml version="1.0" encoding="utf-8"?> 
<?mso-application progid="Word.Document"?> 
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"> 
    <w:body> 
    <w:p> 
     <w:r> 
     <w:t>MS-2524, XML Web Services Programming</w:t> 
     </w:r> 
    </w:p> 
    <w:p> 
     <w:r> 
     <w:t>MS-2124, C# Programming</w:t> 
     </w:r> 
    </w:p> 
    <w:p> 
     <w:r> 
     <w:t>NET2, .NET 2.0 Early Adapter</w:t> 
     </w:r> 
    </w:p> 
    </w:body> 
</w:wordDocument> 

のために、このMS Wordのドキュメントを生成することができますこの回答:https://stackoverflow.com/a/34095/30225

Office 2007のdocxに相当するものを使用するか、2003年のドキュメントを生成して2007年に公開するだけです。

関連する問題