Devexpress和Aspose.Cells两种打印方式

            using (SpreadsheetControl sc = new SpreadsheetControl())
            {
                sc.LoadDocument(@"C:UsersWSDesktop工作簿1.xlt");
                DevExpress.Spreadsheet.Worksheet sheet = sc.ActiveWorksheet;
                //sheet.Pictures.AddPicture(@"C:UsersWSDesktop二维码.png", sheet.Cells["A1"]);

                sheet.Pictures.AddPicture(CreateBarCode("123"),0,0,150,100);
                

                using (PrintingSystem printSys = new PrintingSystem())
                using (PrintableComponentLink comLink = new PrintableComponentLink(printSys))
                {
                    comLink.Component = sc.Document;
                    comLink.PaperKind = PaperKind.A4;//纸张
                    comLink.Landscape = false;//横向,纵向
                    //comLink.CustomPaperSize = new Size(700, 500); 自定义纸张大小
                    string printerName = new PrintDocument().PrinterSettings.PrinterName;//获取默认打印机名
                    comLink.Print(printerName);
                }
            }
            using (Aspose.Cells.Workbook wb = new Workbook(@"C:UsersWSDesktop工作簿1.xlt"))
            using (Aspose.Cells.Worksheet sheet = wb.Worksheets[0])
            {

                sheet.Cells["A1"].Value = 11;

                sheet.PageSetup.PaperSize = PaperSizeType.PaperA4;
                sheet.PageSetup.CustomPaperSize(7, 5);
                sheet.PageSetup.Orientation = PageOrientationType.Landscape;

                //sheet.PageSetup.CenterHorizontally = true; 水平居中
                //sheet.PageSetup.CenterVertically = true; 垂直居中

                ImageOrPrintOptions options = new ImageOrPrintOptions();
                //options.OnePagePerSheet = true;//是否一页输出所有内容
                SheetRender sr = new SheetRender(sheet, options);
                sr.ToPrinter("Microsoft XPS Document Writer");
            }
原文地址:https://www.cnblogs.com/developer-ws/p/14798598.html