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");
                }
  • 相关阅读:
    oracle创建表空间自增长和创建用户
    Cmd Markdown 简明语法手册
    Excel VBA修改不同文件簿sheet页名字
    常用JS(JQ)插件研究
    CSS颜色大全(转载)
    React框架学习
    不同浏览器中空格符的兼容问题
    VHDL----基础知识1
    串口通讯1---单片机
    Qt5 程序发布打包
  • 原文地址:https://www.cnblogs.com/developer-ws/p/14798598.html
Copyright © 2011-2022 走看看