.xmlとして保存してからコンテンツを解析するdocxテンプレートがあります。次に、新しい更新されたWord文書を生成しています。ドキュメントという単語が生成された後、それを開くことができません。「ドキュメントが破損しています」と表示されます。[OK]を押します。次に、「ドキュメントを取得する場合は[OK]を押します」と表示されます。[OK]を押します。次に、更新されたドキュメントを取得します。これは毎回発生します。スタンドアロンのJavaアプリケーションと同じプログラムを作成しました。スタンドアロンのJavaアプリケーションを介して生成されたドキュメントは、エラーなしで開きます。誰かが私にこれについての洞察を提供できますか?サーバー側でも同じコードを使用しました。
これが私がドキュメントを生成するために使用するコードです。
try {
// Prepare the DOM document for writing
Source source = new DOMSource(doc);
// Prepare the output file
FileOutputStream file = new FileOutputStream(filename);
Result result = new StreamResult(file);
// Write the DOM document to the file
Transformer xformer = TransformerFactory.newInstance()
.newTransformer();
xformer.transform(source, result);
file.close();
} catch (TransformerConfigurationException e) {
System.out.println("Transformation Configuration Excepiton in WriteXMLFile");
} catch (TransformerException e) {
System.out.println("Transformation Excepiton in WriteXMLFile");
} catch (Exception e) {
System.out.println("Transformation Excepiton in WriteXMLFile");
e.printStackTrace();
}