• 用Aspose.Cells把Excel文件转成PDF


    Aspose.Cells版本:21.10.0

     1 [HttpPost]
     2 [Route("api/report/ConvertExcelToPDF")]
     3 public HttpResponseMessage ConvertExcelToPDF(string excelPath)
     4 {
     5     try
     6     {
     7         var licensePath = @"C:Aspose.Total.lic";
     8         var license = new License();
     9         license.SetLicense(licensePath);
    10         var wb = new Workbook(excelPath);
    11 
    12         var pdfPath = Path.ChangeExtension(excelPath, ".pdf");
    13         var pdfSaveOptions = new PdfSaveOptions();
    14         pdfSaveOptions.OnePagePerSheet = true;
    15         //pdfSaveOptions.AllColumnsInOnePagePerSheet = true;
    16 
    17         wb.Save(pdfPath, pdfSaveOptions);
    18 
    19         return new HttpResponseMessage()
    20         {
    21             Content = new StringContent(pdfPath, Encoding.UTF8)
    22         };
    23     }
    24     catch (Exception ex)
    25     {
    26         LogManager.Logger.Error(ex);
    27         return new HttpResponseMessage()
    28         {
    29             Content = new StringContent(ex.Message, Encoding.UTF8)
    30         };
    31     }
    32 }
  • 相关阅读:
    OC
    OC
    OC
    OC
    OC
    Oracle wm_concat()函数
    字符串拼接
    easyui扩展数据表格点击加号拓展
    子tab里面新增tab(top.jQuery)
    combox datagrid重复请求问题
  • 原文地址:https://www.cnblogs.com/elliot-lei/p/15437540.html
Copyright © 2020-2023  润新知