Microsoft® Excel Belgesi Meta Verilerini C++ aracılığıyla yönetin
C++ uygulamaları içindeki özel ve yerleşik Excel belge özelliklerini görüntüleyin, ekleyin, güncelleyin, kaldırın veya çıkarın.
Excel’de Meta Veri - Excel dosyası meta verileri nasıl görüntülenir, eklenir ve kaldırılır. C++ Excel Kütüphanesi kolaylaştırıcılar, yazar adı, başlık, belge istatistikleri vb. gibi yerleşik / sistem tanımlı özellikleri destekleyerek, bazen son dosyanın ne zaman değiştirildiğini veya kaydedildiğini kontrol etmek gibi özel / kullanıcı tanımlı özelliklerle birlikte kolay bir şekilde yapılır. ad/değer çiftleri. Süreci otomatikleştirmek için kütüphane, büyük meta veri Excel dosyalarının oluşturulmasını ve korunmasını destekler. Çalışma kitabı class Bir çalışma kitabını yola, akışa ve özel FileFormatType’a göre açar. Bu nedenle dosyayı daha sonraki işlemler için uygun yöntemle yükleyin. Aşağıda listelenen olasılıklardan birkaçı ve geliştiriciler, uygulama gereksinimlerine göre kodlarını kolayca geliştirebilirler.
Yerleşik Özellikleri Okuyun ve Güncelleyin
Yerleşik özellikleri otomatikleştirmek için API şunu sağlar: GetBuiltInDocumentProperties() Elektronik tablonun tüm yerleşik belge özelliklerini temsil eden DocumentProperties koleksiyonunu döndüren yöntem. Tüm yerleşik özelliklere eriştikten sonra, GetTitle(), GetSubject() vb. gibi ilgili yöntemleri kullanarak ilgili özelliklere erişin. Özellikleri güncellemek için API, SetTitle, SetSubject, SetAuthor, SetComments vb. gibi yöntemleri sağlar. yerleşik belge özelliği koleksiyonu gerekli işlev için.
C++ Okunacak Kod Sistem Tanımlı Özellikler
Aspose::Cells::Startup(); | |
//Source directory path | |
U16String dirPath = u"..\\Data\\LoadingSavingForMetadata\\"; | |
//Paths of source and output excel files | |
U16String samplePath = dirPath + u"sample-metadata-properties.xlsx"; | |
//Load the sample excel file | |
Workbook wb(samplePath); | |
//Read built-in title and subject properties | |
U16String strTitle = wb.GetBuiltInDocumentProperties().GetTitle(); | |
U16String strSubject = wb.GetBuiltInDocumentProperties().GetSubject(); | |
std::cout << "Title: " << strTitle.ToUtf8() << std::endl; | |
std::cout << "Subject: " << strSubject.ToUtf8() << std::endl; | |
Aspose::Cells::Cleanup(); |
C++ Yerleşik Özellikleri Güncelleme Kodu
Aspose::Cells::Startup(); | |
//Source directory path | |
U16String dirPath = u"..\\Data\\LoadingSavingForMetadata\\"; | |
//Output directory path | |
U16String outPath = u"..\\Data\\Output\\"; | |
//Paths of source and output excel files | |
U16String samplePath = dirPath + u"sample-metadata-properties.xlsx"; | |
U16String outputPath = outPath + u"output-metadata-properties.xlsx"; | |
//Load the sample excel file | |
Workbook wb(samplePath); | |
//Modify built-in title and subject properties | |
U16String strTitle = u"Aspose.Cells New Title"; | |
U16String strSubject = u"Aspose.Cells New Subject"; | |
wb.GetBuiltInDocumentProperties().SetTitle(strTitle); | |
wb.GetBuiltInDocumentProperties().SetSubject(strSubject); | |
//Save the output excel file | |
wb.Save(outputPath); | |
Aspose::Cells::Cleanup(); |
Özel Tanımlı Özellikleri Görüntüleme ve Ekleme
Özel özelliklerin işlenmesi için API şunu sağlar: Çalışma Kitabı::GetCustomDocumentProperties elektronik tablonun tüm özel belge özellikleri koleksiyonunu döndürür. İlk olarak bu yöntemle özel özelliklere erişen geliştiriciler, AddIDocumentProperty, AddLinkToContentProperty gibi özellikleri eklemek için ilgili yöntemleri kullanabilir ve benzer şekilde sırasıyla içeriğe ve bağlantılı aralığa bağlanan özel belge özellik değerini güncellemek için UpdateLinkedPropertyValue, UpdateLinkedRange’ı kullanabilir. Geliştiriciler ilgili yöntemi şuradan kullanabilir: özel belge özelliklerinin toplanması .
C++ Özel Özellikleri Görüntüleme Kodu
Aspose::Cells::Startup(); | |
//Source directory path | |
U16String dirPath = u"..\\Data\\LoadingSavingAndConverting\\"; | |
//Paths of source and output excel files | |
U16String samplePath = dirPath + u"sample-metadata-properties.xlsx"; | |
//Load the sample excel file | |
Workbook wb(samplePath); | |
//Read the custom property | |
U16String strCustomPropName = u"MyCustom1"; | |
U16String strCustomPropValue = wb.GetCustomDocumentProperties().Get(strCustomPropName).ToString(); | |
U16String myCustom1 = u"\r\nMyCustom1: "; | |
std::cout << myCustom1.ToUtf8() << strCustomPropValue.ToUtf8() << std::endl; | |
Aspose::Cells::Cleanup(); |
C++ Excel Dosyasına Meta Veri Ekleme Kodu
Aspose::Cells::Startup(); | |
//Source directory path | |
U16String dirPath =u"..\\Data\\LoadingSavingAndConverting\\"; | |
//Output directory path | |
U16String outPath = u"..\\Data\\Output\\"; | |
//Paths of source and output excel files | |
U16String samplePath = dirPath + u"sample-metadata-properties.xlsx"; | |
U16String outputPath = outPath + u"output-metadata-properties.xlsx"; | |
//method 1 | |
//Load the sample excel file | |
Workbook wb(samplePath); | |
//Add a new custom property | |
U16String strCustomPropName = u"MyCustom5"; | |
U16String strCustomPropValue = u"This is my custom five."; | |
wb.GetCustomDocumentProperties().Add(strCustomPropName, strCustomPropValue); | |
//Save the output excel file | |
wb.Save(outputPath); | |
////method 2 | |
////Load the sample excel file | |
//Metadata::MetadataOptions options(Metadata::MetadataType::Document_Properties); | |
//Metadata::WorkbookMetadata meta(samplePath, options); | |
////Add a new custom property | |
//meta.GetCustomDocumentProperties().Add(strCustomPropName, strCustomPropValue); | |
////Save the output excel file | |
//meta.Save(outputPath); | |
Aspose::Cells::Cleanup(); |