如何向用户隐藏转换过程

时间:2019-03-21 03:22:27

标签: c# excel pdf

在excelWorkbook.ExportAsFixedFormat行中,excel转换为pdf。伴随着转换进度弹出窗口。如何向用户隐藏此过程?

    public void ConvertExcelToPdf(string fileName)
    {
        Excel.Application excelApplication = new Excel.ApplicationClass();

        excelApplication.ScreenUpdating = false;
        excelApplication.DisplayAlerts = false;
        excelApplication.Visible = false;

        Excel.Workbook excelWorkbook = excelApplication.Workbooks.Open(fileName + ".xlsx", null, true);

        if (excelWorkbook == null)
            excelApplication.Quit();

        excelWorkbook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, fileName + ".pdf");

        excelWorkbook.Close(false);
        excelApplication.Quit();
    }

0 个答案:

没有答案