LoginSignup
0
0

More than 3 years have passed since last update.

C# PowerPointファイルのプロパティを設定・読み込む

Posted at

PowerPointファイルのプロパティは ファイルの内容を示し、そのファイルを特定するためのものです。 ドキュメントのプロパティには、タイトル、作成者名、件名などのほかに、ドキュメントのトピックや内容を特定するキーワードがあります。
この記事では Spire. Presentationを通じてPowerPointファイルのプロパティを設定・読み込む方法をご紹介していきます。

下準備

1.E-iceblueの公式サイトからFree Spire. Presentation無料版をダウンロードしてください。


2.Visual Studioを起動して新規プロジェクトを作成してから、インストールされたファイルにあった相応しいSpire. Presentation.dllを参照に追加してください。
(Net 4.0を例としたら、デフォルトパスは“Bin→NET4.0→Presentation.dll”というようになります。)


プロパティの設定


using Spire.Presentation;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{

//PPTを作成します。
Presentation ppt = new Presentation();

//プロパティを設定します。
ppt.DocumentProperty.Title = "パンダについて";
ppt.DocumentProperty.Subject = "パンダの竹";
ppt.DocumentProperty.Author = "パンダンさん";
ppt.DocumentProperty.Manager = "パンダのマネジャー";
ppt.DocumentProperty.Company = "パンダ会社";
ppt.DocumentProperty.Category = "動物";
ppt.DocumentProperty.Keywords = "パンダ";
ppt.DocumentProperty.Comments = "パンダさんのお嫁さんってだれ?";

//保存します。
ppt.SaveToFile("プロパティ.pptx", FileFormat.Pptx2013);
}
 } 
  }

プロパティを読みこむ


using Spire.Presentation;
using System;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{

//PPTをロードします。
Presentation ppt = new Presentation();
ppt.LoadFromFile("プロパティ.pptx");

//プロパティを読み込みます。
Console.WriteLine("タイトル: " + ppt.DocumentProperty.Title);  
Console.WriteLine("サブタイトル: " + ppt.DocumentProperty.Subject);
Console.WriteLine("作成者: " + ppt.DocumentProperty.Author);
Console.WriteLine("管理者: " + ppt.DocumentProperty.Manager);
Console.WriteLine("会社名: " + ppt.DocumentProperty.Company);
Console.WriteLine("分類: " + ppt.DocumentProperty.Category);
Console.WriteLine("キーワード: " + ppt.DocumentProperty.Keywords);
Console.WriteLine("コメント: " + ppt.DocumentProperty.Comments);

Console.ReadKey();
}
 }
  }














0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0