示例#1
0
        /// <summary>
        /// 根据格式 自动识别打印
        /// </summary>
        /// <param name="path"></param>
        /// <param name="horizontal"></param>
        /// <returns></returns>
        public static bool Print(string path, int copies, Duplex horizontal = Duplex.Simplex)
        {
            if (Utils.CheckFileExists(path))
            {
                string exName = Path.GetExtension(path).ToLower().Remove(0, 1);

                if (exName.Contains("doc"))
                {
                    PrintDoc(path, copies, horizontal);
                }
                if (exName.Contains("xls"))
                {
                    PrintXLS(path, copies, horizontal);
                }
                else if (exName.Equals("pdf"))
                {
                    PrintPDF(path, copies, horizontal);
                }
                else if (Array.IndexOf(ImageFormatNameArray, exName) != -1)
                {
                    PrintPicture(path, copies, horizontal);
                }
                return(true);
            }
            return(false);
        }
示例#2
0
        private void AddExcelFile_Click(object sender, RoutedEventArgs e)
        {
            string path = FileUtils.SelectSingleExcelFile();

            if (Utils.CheckFileExists(path))
            {
                IList <PrintFileModel> fileNameCustoms = SheetToList(path);
                if (fileNameCustoms != null)
                {
                    addFilePagerPage.AddObject(fileNameCustoms);
                }
            }
        }