//测试:转换为pdf
//在下面两个文件夹中找到 office 和 Microsoft.Office.Interop.Excel 两个dll
//C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c
//C:\Windows\assembly\GAC_MSIL\office\15.0.0.0__71e9bce111e9429c
private void button2_Click(object sender, EventArgs e)
{
string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Sample\wb.xlsx";
string filePath2 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Sample\wb.pdf";
//List<string> files = new List<string>();
//files.Add(filePath);
Application application = new ApplicationClass();
Workbook workbook = application.Workbooks.Open(filePath);
workbook.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, filePath2, XlFixedFormatQuality.xlQualityStandard);
}
//测试:转换为pdf
//在下面两个文件夹中找到 office 和 Microsoft.Office.Interop.Excel 两个dll
//C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c
//C:\Windows\assembly\GAC_MSIL\office\15.0.0.0__71e9bce111e9429c
private void button2_Click(object sender, EventArgs e)
{
string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Sample\wb.xlsx";
string filePath2 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Sample\wb.pdf";
//List<string> files = new List<string>();
//files.Add(filePath);
Application application = new ApplicationClass();
Workbook workbook = application.Workbooks.Open(filePath);
workbook.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, filePath2, XlFixedFormatQuality.xlQualityStandard);
}
---
我经历了无数挫折,花费了5个小时才在互联网的阴暗角落看到了有用的信息。
不用客气,拿去用