把Excell转成PDF
需要引入的Dll:
Interop.ACRODISTXLib.dll
Microsoft.Office.Interop.Excel.dll
using System.Reflection;
using ExcelOLE = Microsoft.Office.Interop.Excel;
using PDFOLE = ACRODISTXLib;
private void ExcellFillPDF()
{
ExcelOLE.Application excel;
ExcelOLE._Workbook workbook;
ExcelOLE._Worksheet worksheet;
PDFOLE.PdfDistiller PDF;
try
{
excel = new ExcelOLE.Application();
excel.Visible = true;
workbook = (ExcelOLE._Workbook)(excel.Workbooks.Add( Missing.Value ));
worksheet = (ExcelOLE._Worksheet)workbook.ActiveSheet;
worksheet.Cells[1, 1] = "PDF FILE";
//Make psfile
worksheet.PrintOut(Type.Missing, Type.Missing, Type.Missing,Type.Missing,
"AdobePDF 8.0 J",
true,
Type.Missing,
"c:\\pdffile.ps");
//Start Acrobat Distiller
PDF = new PDFOLE.PdfDistiller();
//Convert to pdffile from psfile
PDF.FileToPDF("c:\\pdffile.ps", "c:\\pdffile.pdf", "");
excel.UserControl = true;
}
catch(Exception ex)
{
}
}