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 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.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);
            }
            // ExEnd:1
        }
コード例 #3
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
        }
コード例 #4
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
        }
コード例 #5
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.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);
            // ExEnd:1
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: MKGAURAB/ASPOSETEST
        private void updateProperties(string dirFile)
        {
            foreach (string fileName in Directory.GetFiles(dirFile))
            {
                if (Path.GetExtension(fileName) == ".xlsx" || Path.GetExtension(fileName) == ".XLSX" ||
                    Path.GetExtension(fileName) == ".XLS" ||
                    Path.GetExtension(fileName) == ".xls" ||
                    Path.GetExtension(fileName) == ".xlsm" ||
                    Path.GetExtension(fileName) == ".XLSM")
                {
                    try
                    {
                        Workbook workbook = new Workbook(fileName);
                        //Get built-in properties of the excel file in a collection object
                        Aspose.Cells.Properties.DocumentPropertyCollection builtInProperties = workbook.Worksheets.BuiltInDocumentProperties;

                        //Get individual property
                        Aspose.Cells.Properties.DocumentProperty propertyAuthor            = builtInProperties["Author"];
                        Aspose.Cells.Properties.DocumentProperty propertylastSavedByAuthor = builtInProperties["LastSavedBy"];

                        //Change individual property value as required
                        propertyAuthor.Value            = author;
                        propertylastSavedByAuthor.Value = lastsavedby;

                        //Save the modified workbook
                        workbook.Save(fileName);
                        totalfilecount++;
                        Console.WriteLine(Path.GetFileName(fileName) + " is changed.\n" + "{ Author: " + author + ", LastSavedBy: " + lastsavedby + " }\n\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine(Path.GetFileName(fileName) + " is not a genuine Spreadsheet file / my have been corrupted.\n");
                    }
                }
                else if (Path.GetExtension(fileName) == ".docx" || Path.GetExtension(fileName) == ".DOCX" ||
                         Path.GetExtension(fileName) == ".DOC" || Path.GetExtension(fileName) == ".doc")
                {
                    try
                    {
                        Document doc = new Document(fileName);

                        //Get built-in properties of the excel file in a collection object
                        Aspose.Words.Properties.DocumentPropertyCollection builtInProperties = doc.BuiltInDocumentProperties;

                        //Get individual property
                        Aspose.Words.Properties.DocumentProperty propertyAuthor            = builtInProperties["Author"];
                        Aspose.Words.Properties.DocumentProperty propertylastSavedByAuthor = builtInProperties["LastSavedBy"];

                        //Change individual property value as required
                        propertyAuthor.Value            = author;
                        propertylastSavedByAuthor.Value = lastsavedby;

                        //Save the modified workbook
                        doc.Save(fileName);
                        totalfilecount++;
                        Console.WriteLine(Path.GetFileName(fileName) + " is changed.\n" + "{ Author: " + author + ", LastSavedBy: " + lastsavedby + " }\n\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine(Path.GetFileName(fileName) + " is not a genuine Document file / my have been corrupted.\n");
                    }
                }
            }
        }