Convert Excel to PDF using JavaScript

后端 未结 2 1479
终归单人心
终归单人心 2021-01-17 07:00

How can I convert Excel documents (files) to PDF in an automated fashion? I am trying to adapt the solution found here to Excel. So far I have this:

var fso          


        
2条回答
  •  遇见更好的自我
    2021-01-17 07:24

    You're clobbering objExcel on line 15:

    var objExcel = objExcel.Workbooks.Open(docPath);
    

    Those lines of code need to use a different variable, e.g.:

    var objWorkbook = objExcel.Workbooks.Open(docPath);
    
    var wdFormatPdf = 57;
    objWorkbook.SaveAs(pdfPath, wdFormatPdf);
    objWorkbook.Close();
    

提交回复
热议问题