public static void Run()
        {
            // ExStart:1
            // 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");
            // ExEnd:1
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            //ExStart:1
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            //Instantiate a Workbook object
            //Open an Excel file
            Workbook workbook = new Workbook(dataDir + "Book1.xls");

            //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 index
            Aspose.Cells.Properties.DocumentProperty customProperty1 = customProperties[3];

            //Accessing a custom document property by using the property name
            Aspose.Cells.Properties.DocumentProperty customProperty2 = customProperties["Owner"];

            System.Console.WriteLine(customProperty1.Name + " -> " + customProperty1.Value);
            System.Console.WriteLine(customProperty2.Name + " -> " + customProperty2.Value);

            //Retrieve a list of all custom document properties of the Excel file
            Aspose.Cells.Properties.CustomDocumentPropertyCollection customPropertiesCollection = workbook.Worksheets.CustomDocumentProperties;

            //Adding a custom document property to the Excel file
            Aspose.Cells.Properties.DocumentProperty publisher = customPropertiesCollection.Add("Publisher", "Aspose");

            //Add link to content.
            customPropertiesCollection.AddLinkToContent("Owner", "MyRange");
            //Accessing the custom document property by using the property name
            Aspose.Cells.Properties.DocumentProperty customProperty3 = customPropertiesCollection["Owner"];
            //Check whether the property is lined to content
            bool islinkedtocontent = customProperty3.IsLinkedToContent;
            //Get the source for the property
            string source = customProperty3.Source;

            //Save the file with added properties
            workbook.Save(dataDir + "Test_Workbook.out.xls");

            //Removing a custom document property
            customProperties.Remove("Publisher");

            //Save the file with added properties
            workbook.Save(dataDir + "Test_Workbook_RemovedProperty.out.xls");
            //ExEnd:1
        }
コード例 #3
0
        public static void Run()
        {
            // ExStart:1
            // 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");
            // ExEnd:1
        }