Esempio n. 1
0
        /// <summary>
        /// 另存为Xps文档
        /// </summary>
        /// <param name="data">数据</param>
        /// <param name="fileName">文件名称</param>
        public void SaveAsXps(object data, string fileName)
        {
            if (doc == null)
            {
                throw new Exception(TEMPLATEFILE_NOT_OPEN);
            }
            fileName = WordOperator.InitalizeValideFileName(fileName);
            string extension = System.IO.Path.GetExtension(fileName);

            if (string.IsNullOrEmpty(extension))
            {
                fileName += ".xps";
            }
            else
            {
                fileName = extension == ".xps" ? fileName : fileName.Replace(extension, ".xps");
            }
            bool success = OnSetParamValue(data);

            if (success)
            {
                WordOperator.InitalzieDirectory(fileName);
                doc.Save(fileName);
                Close();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 另存为Xps文档
        /// </summary>
        /// <param name="data">数据</param>
        /// <param name="fileName">文件名称</param>
        public void SaveAsJpeg(object data, string fileName)
        {
            if (doc == null)
            {
                throw new Exception(TEMPLATEFILE_NOT_OPEN);
            }
            fileName = WordOperator.InitalizeValideFileName(fileName);
            string extension = System.IO.Path.GetExtension(fileName);

            if (string.IsNullOrEmpty(extension))
            {
                fileName += ".jpg";
            }
            else
            {
                fileName = extension == ".jpg" ? fileName : fileName.Replace(extension, ".jpg");
            }
            bool success = OnSetParamValue(data);

            if (success)
            {
                WordOperator.InitalzieDirectory(fileName);
                ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Jpeg);
                options.Resolution = 300;
                doc.Save(fileName, options);
                Close();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 保存文件
        /// </summary>
        public void Save()
        {
            if (doc == null)
            {
                throw new Exception(TEMPLATEFILE_NOT_OPEN);
            }
            fileName = WordOperator.InitalizeValideFileName(fileName);
            string extension = System.IO.Path.GetExtension(fileName);

            if (string.IsNullOrEmpty(extension))
            {
                fileName += ".doc";
            }
            else
            {
                fileName = extension == ".doc" ? fileName : fileName.Replace(extension, ".doc");
            }
            WordOperator.InitalzieDirectory(fileName);
            doc.Save(fileName, SaveFormat.Doc);
        }
Esempio n. 4
0
        /// <summary>
        /// 另存为
        /// </summary>
        /// <param name="data">数据</param>
        /// <param name="fileName">文件名称</param>
        /// <param name="close">是否关闭</param>
        public void SaveAsMultiFile(object data, string fileName)
        {
            if (doc == null)
            {
                throw new Exception(TEMPLATEFILE_NOT_OPEN);
            }
            fileName = WordOperator.InitalizeValideFileName(fileName);
            string extension = System.IO.Path.GetExtension(fileName);

            if (string.IsNullOrEmpty(extension))
            {
                fileName += ".doc";
            }
            else
            {
                fileName = extension == ".doc" ? fileName : fileName.Replace(extension, ".doc");
            }
            bool success = OnSetParamValue(data);

            if (success)
            {
                WordOperator.InitalzieDirectory(fileName);
                doc.Save(fileName, SaveFormat.Doc);
                ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Jpeg);
                options.Resolution = 300;
                fileName           = fileName.Replace(".doc", "");
                string number = fileName.Substring(fileName.Length - 1);
                int    order  = 1;
                Int32.TryParse(number, out order);
                fileName = fileName.Substring(0, fileName.Length - 1);
                string nameFile = fileName + (order == 0 ? number : order.ToString()) + ".jpg";
                for (int i = 0; i < doc.PageCount; i++)
                {
                    options.PageIndex = i;
                    doc.Save(nameFile, options);
                    order++;
                    nameFile = fileName + order.ToString() + ".jpg";
                }
                Close();
            }
        }