zoukankan      html  css  js  c++  java
  • NetCore 使用Aspose.Cell把Excel转换成PDF

    NetCore 使用Aspose.Cell把Excel转换成PDF

    引言

    最近工作需要把生成的Excel转换为Pdf文件,网上有几个方案 Spire.XLS 软件收费、转换后文件还可以、但是收费。。。。 其他方案也类似,要么收费、要么转换后格式对 后来无意中发现这个文章使用Aspose可以导出PDF文件

    Aspose也是收费软件, 下载破解版: https://pan.baidu.com/s/1dRwY0mjeIbbAhWQgC3fLSA 提取码: 5eyr

    只需要简单几句代码就可以导出PDF 下载完成后、把DLL文件复制到项目Bin文件夹中 Vs中引用DLL文件 如下图所示 引用完成后

    导出PDF

    ``` private string ExportPDF(string execlPath, string pdfName) { try { Workbook wb = new Workbook(execlPath); foreach (Worksheet item in wb.Worksheets) { item.PageSetup.PaperSize = Aspose.Cells.PaperSizeType.PaperA4; item.PageSetup.Zoom = 98;//打印时页面设置,缩放比例 item.PageSetup.LeftMargin = 0; //左边距为0 item.PageSetup.RightMargin = 0; //右边距为0 item.PageSetup.CenterHorizontally = true;//水平居中 } wb.Save(pdfName, SaveFormat.Pdf); if (System.IO.File.Exists(execlPath)) { System.IO.File.Delete(execlPath); } return pdfName; } catch (Exception ex) { var logger = NLog.LogManager.GetCurrentClassLogger(); logger.Error("BudgetController_ExportPDF:" + ex.Message); throw; }

    }

    <h2>原始Excel截图</h2>
    <img class="alignnone wp-image-251 size-full" src="http://www.netcore.pub/wp-content/uploads/2019/12/20191227154758486_30872.png" alt="" width="755" height="777" />
    <h2>导出PDF截图</h2>
    <img class="alignnone wp-image-252 size-full" src="http://www.netcore.pub/wp-content/uploads/2019/12/20191227154821741_16448.png" alt="" width="870" height="948" />
  • 相关阅读:
    墙内正确安装docker和docker-compose的方法
    VS2015编译ncnn
    caffe模型转ncnn模型
    Ncnn-Installation-on-Windows
    CV2 Fourcc解析
    手动安装OpenCV下的IPP加速库
    Ubuntu下安装Caffe
    Linux安装CUDA教程参考
    最正确的姿势安装cudnn,网上大多数教程都太坑了
    安装多版本cuda时,nvcc和cuda版本不一致问题
  • 原文地址:https://www.cnblogs.com/Zenderblogs/p/12107874.html
Copyright © 2011-2022 走看看