C# 字符串不可分配给参数类型Excel.XIFixedFormatType

C# 字符串不可分配给参数类型Excel.XIFixedFormatType,c#,asp.net,winforms,excel,C#,Asp.net,Winforms,Excel,我正在将excel文件转换为pdf文件,但当我传入用于导出的字符串时,出现此错误(红色下划线convertFilePath)参数类型字符串不能分配给参数类型Microsoft.Office.Interop.excel.XIFixedFormatType var convertFileId = Guid.NewGuid(); var convertFilePath = @"c:\temp\" + convertFileId + ".pdf"; public Microsoft.Office.

我正在将excel文件转换为pdf文件,但当我传入用于导出的字符串时,出现此错误(红色下划线convertFilePath)
参数类型字符串不能分配给参数类型Microsoft.Office.Interop.excel.XIFixedFormatType

var convertFileId = Guid.NewGuid();
var convertFilePath = @"c:\temp\" + convertFileId + ".pdf";



public Microsoft.Office.Interop.Excel.Workbook excelWorkbook { get; set; }
    void ExcelToPdf(string convertFilePath)
    {
        Microsoft.Office.Interop.Excel.Application appWord = new Microsoft.Office.Interop.Excel.Application();
        excelWorkbook = appWord.Workbooks.Open(DocumentUNCPath.Text);

        excelWorkbook.ExportAsFixedFormat(convertFilePath, WdExportFormat.wdExportFormatPDF);
        excelWorkbook.Close();
        appWord.Quit();
    }

XlFixedFormatType
是一个枚举,您应该传递一个有效值

有关更多信息,请参阅和

例如:

excelWorkbook.ExportAsFixedFormat(xlTypePdf, Filename:=filename);

在ASP.net中,不应该是相反的吗
ExportAsFixedFormat(FileFormat,FilePath)
@SiddharthRout即使在切换它们时,我仍然收到相同的错误。