使用Interop.Excel将Excel转换为PDF时不显示图像
我正在使用Interop.Excel将Excel(xlsx)(2010)转换为应用程序的PDF。在我的显影机上,它工作正常,图像显示正确。但是,在服务器上,当excel转换为PDF时,图像(一些通过代码插入,另一些通过模板文档插入)不会显示在PDF中。查看excel文件时,该文件正常。以下是我用来转换为PDF的代码:使用Interop.Excel将Excel转换为PDF时不显示图像,excel,pdf,interop,Excel,Pdf,Interop,我正在使用Interop.Excel将Excel(xlsx)(2010)转换为应用程序的PDF。在我的显影机上,它工作正常,图像显示正确。但是,在服务器上,当excel转换为PDF时,图像(一些通过代码插入,另一些通过模板文档插入)不会显示在PDF中。查看excel文件时,该文件正常。以下是我用来转换为PDF的代码: Public Shared Function FromExcel(ByVal ExcelFileLocation As String, ByVal PDFFileLocation
Public Shared Function FromExcel(ByVal ExcelFileLocation As String, ByVal PDFFileLocation As String) As Boolean
' Load the new Excel file
' http://msdn.microsoft.com/en-us/library/bb407651(v=office.12).aspx
Dim excelApplication As ApplicationClass = New ApplicationClass()
Dim excelWorkbook As Workbook = Nothing
Dim paramExportFormat As XlFixedFormatType = XlFixedFormatType.xlTypePDF
Dim paramExportQuality As XlFixedFormatQuality = XlFixedFormatQuality.xlQualityStandard
Dim paramOpenAfterPublish As Boolean = False
Dim paramIncludeDocProps As Boolean = True
Dim paramIgnorePrintAreas As Boolean = True
Dim paramFromPage As Object = Type.Missing
Dim paramToPage As Object = Type.Missing
Try
' Open the source workbook.
excelWorkbook = excelApplication.Workbooks.Open(ExcelFileLocation)
' Save it in the target format.
If Not excelWorkbook Is Nothing Then
excelWorkbook.ExportAsFixedFormat(paramExportFormat, _
PDFFileLocation, paramExportQuality, _
paramIncludeDocProps, paramIgnorePrintAreas, _
paramFromPage, paramToPage, paramOpenAfterPublish)
Return True
Else
Return False
End If
Catch ex As Exception
Return False
Finally
' Close the workbook object.
If Not excelWorkbook Is Nothing Then
excelWorkbook.Close(False)
excelWorkbook = Nothing
End If
' Quit Excel and release the ApplicationClass object.
If Not excelApplication Is Nothing Then
excelApplication.Quit()
excelApplication = Nothing
End If
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
End Try
End Function
下面是PDF转换时的屏幕截图
请注意,右上角和右下角的图像是如何不显示的。任何想法都会有帮助
谢谢我在填充单元格和changin单选按钮时遇到了类似的问题——所有图像都会消失 通过将服务帐户切换到本地系统,而不是我最初选择的“本地服务”,我可以使图像不被删除
我仍然坚持这一点,有人知道一些信息吗?另请参见:您是否找到解决方法或解决方案?