ドキュメント プロパティの管理

考えられる使用シナリオ

Aspose.Cells を使用すると、組み込みおよびカスタムのドキュメント プロパティを操作できます。これらを開くための Microsoft Excel インターフェイスは次のとおりです。ドキュメント プロパティ.をクリックするだけです詳細プロパティこのスクリーンショットに示すように、それらを表示します。

todo:画像_代替_文章

ドキュメント プロパティの管理

次のサンプル コードが読み込まれますサンプルエクセルファイル組み込みのドキュメント プロパティを読み取ります。タイトル、件名そしてそれらを変更します。次に、カスタム ドキュメント プロパティも読み取ります。マイカスタム1次に、新しいカスタム ドキュメント プロパティを追加します。MyCustom5と書く出力エクセルファイル.次のスクリーンショットは、サンプル Excel ファイルに対するサンプル コードの効果を示しています。

todo:画像_代替_文章

サンプルコード

//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
//Source directory path
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\");
//Output directory path
StringPtr outPath = new String("..\\Data\\Output\\");
//Paths of source and output excel files
StringPtr samplePath = dirPath->StringAppend(new String(L"sampleManagingDocumentProperties.xlsx"));
StringPtr outputPath = outPath->StringAppend(new String(L"outputManagingDocumentProperties.xlsx"));
//Load the sample excel file
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(samplePath);
//Read built-in title and subject properties
StringPtr strTitle = wb->GetIBuiltInDocumentProperties()->GetTitle();
StringPtr strSubject = wb->GetIBuiltInDocumentProperties()->GetSubject();
StringPtr title = new String("Title: ");
Console::WriteLine(title->StringAppend(strTitle));
StringPtr subject = new String("Subject: ");
Console::WriteLine(subject->StringAppend(strSubject));
//Modify built-in title and subject properties
strTitle = new String("Aspose.Cells New Title");
strSubject = new String("Aspose.Cells New Subject");
wb->GetIBuiltInDocumentProperties()->SetTitle(strTitle);
wb->GetIBuiltInDocumentProperties()->SetSubject(strSubject);
//Read the custom property
StringPtr strCustomPropName = new String("MyCustom1");
StringPtr strCustomPropValue = wb->GetICustomDocumentProperties()->GetObjectByIndex(strCustomPropName)->ToString();
StringPtr myCustom1 = new String("\r\nMyCustom1: ");
Console::WriteLine(myCustom1->StringAppend(strCustomPropValue));
//Add a new custom property
strCustomPropName = new String("MyCustom5");
strCustomPropValue = new String("This is my custom five.");
wb->GetICustomDocumentProperties()->AddIDocumentProperty(strCustomPropName, strCustomPropValue);
//Save the output excel file
wb->Save(outputPath);

コンソール出力

これは、上記のサンプル コードを提供されたコマンドで実行したときのコンソール出力です。サンプルエクセルファイル.

 Title: Aspose Team

Subject: Aspose.Cells for C++

MyCustom1: This is my custom one.