public static void ConvertExcelToPdf(string excelFileIn, string pdfFileOut)
{
msExcel.Application excel = new msExcel.Application();
try
{ excel.Visible = false;
excel.ScreenUpdating = false;
excel.DisplayAlerts = false;
FileInfo excelFile = new FileInfo(excelFileIn);
string filename = excelFile.FullName;
msExcel.Workbook wbk = excel.Workbooks.Open(filename, missing,
missing, missing, missing, missing, missing,
missing, missing, missing);
wbk.Activate();
object outputFileName = pdfFileOut;
//wbk.FullName.Replace(".xslx", ".pdf");
msExcel.XlFixedFormatType fileFormat = msExcel.XlFixedFormatType.xlTypePDF;
// Save document into PDF Format
wbk.ExportAsFixedFormat(fileFormat, outputFileName,
Microsoft.Office.Interop.Excel.XlFixedFormatQuality.xlQualityMinimum, missing, false,
missing, missing,missing,
missing);
object saveChanges = msExcel.XlSaveAction.xlDoNotSaveChanges;
((msExcel._Workbook)wbk).Close(saveChanges, missing, missing);
wbk = null;
}
catch (Exception e)
finally
((msExcel._Application)excel).Quit();
excel = null;