Officeオートメーションを使用せずにPowerPointプレゼンテーションを生成するためのテクニックにはどのようなものがありますか?

StackOverflow https://stackoverflow.com/questions/825247

質問

Officeオートメーションを使用してPowerPointプレゼンテーションを自動的に生成することは可能ですが、これはサーバーでの使用は推奨されません。 Officeオートメーションを使用せずにPowerPointプレゼンテーションを生成するにはどうすればよいですか?

役に立ちましたか?

解決

言及されなかった別のオプションは、私たちが最終的に取ったルートで、 ファイル形式= 941B3470-3AE9-4AEE-8F43-C6BB74CD1466&displaylang = en "rel =" noreferrer ">互換性パック XML SDK 1.0を開く何かを機能させることは驚くほど簡単です。

最初に、置き換えが必要なコンテンツの代わりにトークンを配置した汎用テンプレートファイルを準備しました。次に、DocumentFormat.OpenXmlへの参照をプロジェクトに追加する必要があります。コード自体は、DocumentFormat.OpenXmlおよびDocumentFormat.OpenXml.Packaging名前空間を参照します。最後に、スライドをループするコードは次のようになります。

// Open the presentation
PresentationDocument presentation = PresentationDocument.Open(fileName, true);
// Loop through all of the slides in the presentation
foreach (SlidePart slide in presentation.PresentationPart.SlideParts)
{
    // Read the XML out of the slide
    XmlDocument xml = new XmlDocument();
    xml.Load(slide.GetStream());

    // TODO: Your XML manipulation code here

    // Save the updated slide
    xml.Save(slide.GetStream());
}
// Save the updated presentation
presentation.Close();

他のヒント

PowerPoint形式のドキュメントを生成できるライブラリを使用するサーバー側コードを作成できます。たとえば、Javaでは、 Apache POI-HSLF を使用して、プログラムでPPTファイルを生成できます。

何をする必要があるかによっては、「テンプレート」PPTファイルで開始し、プログラムで変更してコンテンツを挿入または編集する方が簡単な場合があります。

サーバー側のテクノロジーがASP.NETの場合、 Aspose.Slides 。それは非常に強力でうまく機能しますが、何をしたいかによっては費用対効果の高いソリューションではないかもしれません。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top