Exemple #1
0
        public CommonResult PrintFile(string filePath, string printType)
        {
            if (!File.Exists(filePath))
            {
                return(JResult.Error("文件不存在"));
            }
            ExcelApp excel = new ExcelApp();

            excel.Open(filePath);

            if (printType == PrintType.Preview.GetHashCode().ToString())
            {
                excel.IsExcelAppVisibled = true;
                excel.PrintPreview();
            }
            else
            {
                var app = excel.Application;
                app.WindowState = XlWindowState.xlNormal;
                app.Width       = app.Height = 0;
                var dialogResult = app.Dialogs[XlBuiltInDialog.xlDialogPrint].Show();
                app.Quit();
            }
            Utils.DeleteExcel();
            excel.Close();
            //File.Delete(filePath);
            return(JResult.Success());
        }
Exemple #2
0
        public CommonResult PrintExcelBase64(string excelBase64, string printType)
        {
            string path       = Utils.NewExcelFullName();
            bool   saveResult = Utils.Base64ToFile(excelBase64, path);

            if (!saveResult)
            {
                return(JResult.Error("不是有效的base64数据"));
            }

            var printResult = PrintFile(path, printType);

            return(printResult);
        }
Exemple #3
0
        public CommonResult PrintExcelUrl(string url, string printType)
        {
            string path       = Utils.NewExcelFullName();
            bool   saveResult = Utils.UrlToFile(url, path);

            if (!saveResult)
            {
                return(JResult.Error("下载文件失败"));
            }

            var printResult = PrintFile(path, printType);

            return(printResult);
        }
Exemple #4
0
        public CommonResult GetVersion()
        {
            var version = Utils.GetAssemblyInfo();

            return(JResult.Success("获取成功", "0", version));
        }