c#excel转pdf
using MSExcel = Microsoft.Office.Interop.Excel;
private bool exceltoPDF(string sourcePath, string targetPath)
{
bool result;
object missing = Type.Missing;
MSExcel.ApplicationClass application = null;
MSExcel.Workbook workBook = null;
try
{
application = new MSExcel.ApplicationClass();
object target = targetPath;
workBook = application.Workbooks.Open(sourcePath, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing, missing, missing, missing, missing);
workBook.ExportAsFixedFormat(MSExcel.XlFixedFormatType.xlTypePDF, target, MSExcel.XlFixedFormatQuality.xlQualityStandard , true, false, missing, missing, missing, missing);
result = true;
}
catch
{
result = false;
}
excel最强教科书完全版pdffinally
{
if (workBook != null)
{
workBook.Close(true, missing, missing);
workBook = null;
}
if (application != null)
{
application.Quit();
application = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
}
return result;
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论