Belge Özelliklerini Yönet

Giriş

Microsoft Excel, elektronik tablo dosyalarına özellikler ekleme yeteneği sağlar. Bu belge özellikleri yararlı bilgiler sağlar ve aşağıda ayrıntıları verildiği gibi 2 kategoriye ayrılır.

  • Sistem tanımlı (yerleşik) özellikler: Yerleşik özellikler, belge başlığı, yazar adı, belge istatistikleri vb. gibi belge hakkında genel bilgiler içerir.
  • Kullanıcı tanımlı (özel) özellikler: Son kullanıcı tarafından ad-değer çifti şeklinde tanımlanan özel özellikler.

Microsoft Excel Kullanarak Belge Özelliklerini Yönetme

Microsoft Excel, Excel dosyalarının belge özelliklerini WYSIWYG tarzında yönetmenizi sağlar. açmak için lütfen aşağıdaki adımları izleyin.Özellikler Excel 2016’da iletişim kutusu.

  1. itibarenDosya menü, seçBilgi.
Bilgi Menüsünün Seçilmesi
yapılacaklar:resim_alternatif_metin
  1. TıklamakÖzelliklerbaşlığını açın ve “Gelişmiş Özellikler"i seçin.
Gelişmiş Özellikler Seçimine Tıklama
yapılacaklar:resim_alternatif_metin
  1. Dosyanın belge özelliklerini yönetin.
Özellikler İletişim Kutusu
yapılacaklar:resim_alternatif_metin
Özellikler iletişim kutusunda Genel, Özet, İstatistikler, İçerik ve Gümrük gibi farklı sekmeler bulunur. Her sekme, dosyayla ilgili farklı türden bilgilerin yapılandırılmasına yardımcı olur. Özel sekmesi, özel özellikleri yönetmek için kullanılır.

Aspose.Cells Kullanarak Belge Özellikleriyle Çalışma

Geliştiriciler, Aspose.Cells API’lerini kullanarak belge özelliklerini dinamik olarak yönetebilir. Bu özellik geliştiricilerin, dosyanın ne zaman alındığı, işlendiği, zaman damgası eklendiği vb. yararlı bilgileri dosyayla birlikte depolamasına yardımcı olur.

Belge Özelliklerine Erişme

Aspose.Cells API’ler, yerleşik ve özel olmak üzere her iki belge özelliği türünü de destekler. Aspose.Cells'Çalışma kitabı class bir Excel dosyasını temsil eder ve bir Excel dosyası gibiÇalışma kitabı sınıf, her biri tarafından temsil edilen birden çok çalışma sayfası içerebilir.Çalışma kağıdı sınıf, oysa çalışma sayfalarının koleksiyonu şu şekilde temsil edilir:Çalışma Sayfası Koleksiyonusınıf.

KullanÇalışma Sayfası KoleksiyonuDosyanın belge özelliklerine aşağıda açıklandığı gibi erişmek için.

İkisi deWorksheetCollection.BuiltInDocumentProperties veWorksheetCollection.CustomDocumentProperties örneğini geri verAspose.Cells.Properties.DocumentPropertyCollection. Bu koleksiyon içerirAspose.Cells.Properties.DocumentPropertyher biri tek bir yerleşik veya özel belge özelliğini temsil eden nesneler.

Bir mülke nasıl erişileceği başvuru şartına bağlıdır, yani; özelliğin dizinini veya adını kullanarakDocumentPropertyCollectionaşağıdaki örnekte gösterildiği gibi.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a Workbook object
// Open an Excel file
Workbook workbook = new Workbook(dataDir + "sample-document-properties.xlsx");
// Retrieve a list of all custom document properties of the Excel file
Aspose.Cells.Properties.DocumentPropertyCollection customProperties = workbook.Worksheets.CustomDocumentProperties;
// Accessing a custom document property by using the property name
Aspose.Cells.Properties.DocumentProperty customProperty1 = customProperties["ContentTypeId"];
Console.WriteLine(customProperty1.Name + " " + customProperty1.Value);
// Accessing the same custom document property by using the property index
Aspose.Cells.Properties.DocumentProperty customProperty2 = customProperties[0];
Console.WriteLine(customProperty2.Name + " " + customProperty2.Value);

buAspose.Cells.Properties.DocumentPropertyclass, belge özelliğinin adını, değerini ve türünü almaya izin verir:

Üye adı Açıklama ToXXX Yöntemi
boole Özellik veri türü Boolean’dır ToBool
Tarih Özellik veri türü DateTime’dır. Microsoft Excel’in yalnızca depoladığını unutmayın.
tarih bölümü, bu türden özel bir özellikte hiçbir zaman depolanamaz
ToDateTime
Batmadan yüzmek Özellik veri türü Double Çifte
Sayı Özellik veri türü Int32’dir. ToInt
Sicim Özellik veri türü String’dir ToString
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a Workbook object
// Open an Excel file
Workbook workbook = new Workbook(dataDir + "sample-document-properties.xlsx");
// Retrieve a list of all custom document properties of the Excel file
Aspose.Cells.Properties.DocumentPropertyCollection customProperties = workbook.Worksheets.CustomDocumentProperties;
// Accessing a custom document property
Aspose.Cells.Properties.DocumentProperty customProperty1 = customProperties[0];
// Storing the value of the document property as an object
object objectValue = customProperty1.Value;
// Accessing a custom document property
Aspose.Cells.Properties.DocumentProperty customProperty2 = customProperties[1];
// Checking the type of the document property and then storing the value of the
// document property according to that type
if (customProperty2.Type == Aspose.Cells.Properties.PropertyType.String)
{
string value = customProperty2.Value.ToString();
Console.WriteLine(customProperty2.Name + " : " + value);
}

Özel Belge Özellikleri Ekleme veya Kaldırma

Bu konunun başında daha önce açıkladığımız gibi, geliştiriciler yerleşik özellikler ekleyemez veya kaldıramaz çünkü bu özellikler sistem tanımlıdır, ancak kullanıcı tanımlı oldukları için özel özellikler eklemek veya kaldırmak mümkündür.

Özel Özellikler Ekleme

Aspose.Cells API’ler şu bilgileri açığa çıkardı:Eklemek için yöntemCustomDocumentPropertyCollection koleksiyona özel özellikler eklemek için sınıf. buEklemek yöntemi, özelliği Excel dosyasına ekler ve yeni belge özelliği için bir referans olarak bir referans döndürür.Aspose.Cells.Properties.DocumentPropertynesne.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a Workbook object
// Open an Excel file
Workbook workbook = new Workbook(dataDir + "sample-document-properties.xlsx");
// Retrieve a list of all custom document properties of the Excel file
Aspose.Cells.Properties.CustomDocumentPropertyCollection customProperties = workbook.Worksheets.CustomDocumentProperties;
// Adding a custom document property to the Excel file
Aspose.Cells.Properties.DocumentProperty publisher = customProperties.Add("Publisher", "Aspose");
// Saving resultant spreadsheet
workbook.Save(dataDir + "out_sample-document-properties.xlsx");

“İçeriğe bağlantı” Özel Özelliğini Yapılandırma

Belirli bir aralığın içeriğine bağlı özel bir özellik oluşturmak içinCustomDocumentPropertyCollection.AddLinkToContent yöntem ve geçiş özelliği adı ve kaynağı. Bir özelliğin içeriğe bağlı olarak yapılandırılıp yapılandırılmadığını kontrol edebilirsiniz.DocumentProperty.IsLinkedToContent Emlak. Ayrıca, kullanarak kaynak aralığını elde etmek de mümkündür.Kaynak mülkiyetiBelge Özelliğisınıf.

Örnekte basit bir şablon Microsoft Excel dosyası kullanıyoruz. Çalışma kitabı, etiketli tanımlanmış bir adlandırılmış aralığa sahiptir.Aralığım bu da bir hücre değerini ifade eder.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate an object of Workbook
// Open an Excel file
Workbook workbook = new Workbook(dataDir + "sample-document-properties.xlsx");
// Retrieve a list of all custom document properties of the Excel file
Aspose.Cells.Properties.CustomDocumentPropertyCollection customProperties = workbook.Worksheets.CustomDocumentProperties;
// Add link to content.
customProperties.AddLinkToContent("Owner", "MyRange");
// Accessing the custom document property by using the property name
Aspose.Cells.Properties.DocumentProperty customProperty1 = customProperties["Owner"];
// Check whether the property is lined to content
bool islinkedtocontent = customProperty1.IsLinkedToContent;
// Get the source for the property
string source = customProperty1.Source;
// Save the file
workbook.Save(dataDir + "out_sample-document-properties.xlsx");

Özel Özellikleri Kaldırma

Aspose.Cells’i kullanarak özel özellikleri kaldırmak içinDocumentPropertyCollection.Kaldıryöntemini seçin ve kaldırılacak belge özelliğinin adını iletin.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Instantiate a Workbook object
// Open an Excel file
Workbook workbook = new Workbook(dataDir + "sample-document-properties.xlsx");
// Retrieve a list of all custom document properties of the Excel file
Aspose.Cells.Properties.DocumentPropertyCollection customProperties = workbook.Worksheets.CustomDocumentProperties;
// Removing a custom document property
customProperties.Remove("Publisher");
// Save the file
workbook.Save(dataDir + "out_sample-document-properties.xlsx");

ileri konular