zoukankan      html  css  js  c++  java
  • 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");
                }
  • 相关阅读:
    ASCII码表以及不同进制间的O(1)转换
    四则运算表达式的语法分析
    语法分析器初步学习——LISP语法分析
    ASC与HEX之间的转换
    字节存储数据
    进制之间的转换
    java多线程CountDownLatch
    java反射机制
    java注解
    使用javafx实现视频播放器
  • 原文地址:https://www.cnblogs.com/developer-ws/p/14798598.html
Copyright © 2011-2022 走看看