Esempio n. 1
0
        /// <summary> Write propery list into word file </summary>
        /// <param name="fileName"> file path and name (ex. d:\doc1.docx) </param>
        /// <param name="list"> Property list </param>
        internal static void setCustomProperty(string fileName, List <CustomProperty> list)
        {
            List <CustomDocumentProperty> willFillPropertyList = new List <CustomDocumentProperty>();


            foreach (var cp in list)
            {
                var newProp = WordPropertyHelper.parseCustomProperty(cp.PropertyName, cp.PropertyValue, cp.PropertyType);


                if (newProp == null)
                {
                    continue;
                }


                willFillPropertyList.Add(newProp);
            }


            if (willFillPropertyList.Count <= 0)
            {
                throw new ArgumentException(" No property to write into file. ");
            }


            WordPropertyHelper.writeProperty(fileName, willFillPropertyList.ToArray());
        }
Esempio n. 2
0
        /// <summary> Write property into word file </summary>
        /// <param name="fileName"> file path and name (ex. d:\doc1.docx) </param>
        /// <param name="PropertyName"> PropertyName </param>
        /// <param name="PropertyValue"> PropertyValue </param>
        /// <param name="PropertyType"> PropertyType </param>
        private static void SetCustomProperty(string fileName, string PropertyName, object PropertyValue, PropertyTypes PropertyType)
        {
            var newProp = WordPropertyHelper.parseCustomProperty(PropertyName, PropertyValue, PropertyType);

            if (newProp == null)
            {
                throw new ArgumentException(" No property to write into file. ");
            }

            List <CustomDocumentProperty> willFillPropertyList = new List <CustomDocumentProperty>()
            {
                newProp
            };


            WordPropertyHelper.writeProperty(fileName, willFillPropertyList);
        }