locked
ExportAsFixedFormat strange problem RRS feed

  • Question

  • User672522775 posted

    Hello guys:

    i'm developing an application to export Excel file to pdf format.

    when running the application on my local machine , every thing is ok .

    when hosting my application on the iis , i faced a strange problem .

    Problem:

    1-if the host machine's windows version is windows xp sp2 , every thing is ok.

    2-if the host machine's windows version is windows xp sp3 or windows server 2003 sp2 , the application hangs and the conversion process failed .

    i don't know the reason. please it is an urgent issue and i need urgent help

    this is my code sample for conversion process:

    Sub ConvertWorkbookToPDFXPS()' Declare variables to hold references to the Excel ApplicationClass

     ' and Workbook objects.

     Dim excelApplication As ApplicationClass = Nothing

     Dim excelWorkbook As Workbook = Nothing

     Dim missing As Object = System.Reflection.Missing.Value' Declare a variable for the path to the workbook to convert.

     Dim paramSourceBookPath As String = Server.MapPath("Reports.xlsx")' Declare variables for the Document.ExportAsFixedFormat method parameters.

    Dim paramExportFilePath As String = Server.MapPath("MCS.pdf")Dim paramExportFormat As XlFixedFormatType = XlFixedFormatType.xlTypePDFDim paramExportQuality As XlFixedFormatQuality = XlFixedFormatQuality.xlQualityStandardDim 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' Create an instance of Excel.

    excelApplication = New Microsoft.Office.Interop.Excel.Application' Open the source workbook.

    excelWorkbook = excelApplication.Workbooks.Open(Server.MapPath("Reports.xlsx"), Nothing, False)' Save it in the target format.

     If Not excelWorkbook Is Nothing Then

    excelWorkbook.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, Server.MapPath("MCS.pdf"), Microsoft.Office.Interop.Excel.XlFixedFormatQuality.xlQualityStandard, missing, False, missing, missing, False, missing)

    End If

     ' Close the Workbook object.

     If Not excelWorkbook Is Nothing Then

    excelWorkbook.Close(False)

    excelWorkbook = Nothing

    End If

     

    ' Close the ApplicationClass object.

     

    If Not excelApplication Is Nothing Then

    excelApplication.Quit()

    excelApplication =

    Nothing

     

    End If

    GC.Collect()

    GC.WaitForPendingFinalizers()

    GC.Collect()

    GC.WaitForPendingFinalizers()

     

    End Sub

     

    thanks

     

     

    Tuesday, November 17, 2009 4:36 AM

All replies

  • User-1160646140 posted

    I am also getting same error on same location means

    excelWorkbook.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, Server.MapPath("MCS.pdf"), Microsoft.Office.Interop.Excel.XlFixedFormatQuality.xlQualityStandard, missing, False, missing, missing, False, missing)

     

    You found any solution?? please help.

    thanks

    Amit

    Friday, October 29, 2010 2:02 AM
  • User-1160646140 posted

    i Found the solution this required to change security setting. please visit below link.

    http://sqlreporting.blogspot.com/2010/11/office-automation-configuraiton-on.html



    Tuesday, November 2, 2010 6:38 AM