• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

Opening Excel And Getting An Old Version

I am using crystal reports to export to Excel and then opening the file in a new window.  When I run this for a PDF everything works fine but when I export to Excel First I get A Page Cannot be displayed error.  The second time I get an old version of the file.   If anyone else connects and run either report it works perfect.  I have tried ExportToStream and just Export and both do the same thing.  In the export when I look at the file on the harddrive it is correct but when I open in a browser its an old version. Does anyone have any ideas on what would be causing this?
0
curtis591
Asked:
curtis591
  • 11
  • 7
1 Solution
 
Brad Dobyns, CSMCommented:
Can you show us some of your code?

Brad
0
 
curtis591Author Commented:
'This Procedure Returns me the IO stream

 Public Function GenerateReportToStream(ByVal pdataSet As DataSet) As IO.Stream
        cRpt.SetDataSource(pdataSet.Tables(0))
        cRpt.Refresh()
        Select Case cExportType
            Case ExportType.PDF
                Return cRpt.ExportToStream(ExportFormatType.PortableDocFormat)
            Case ExportType.Excel
                Dim objExcelOptions As ExcelFormatOptions = New ExcelFormatOptions
                objExcelOptions.ExcelUseConstantColumnWidth = False
                cRpt.ExportOptions.FormatOptions = objExcelOptions
                Return cRpt.ExportToStream(ExportFormatType.Excel)
            Case Else
                Dim ex As New Exception("DTest")
                Throw ex
        End Select

    End Function



Shared Sub DisplayReportInBrowser(ByRef pPage As System.Web.UI.Page, ByVal pReportStream As System.IO.MemoryStream, ByVal PexportType As IpscoCommon.Common.ExportType)
        ' the code below will create pdfs in memory and stream them to the browser
        ' instead of creating files on disk.
        'Dim x As New System.Web.UI.Page

        Try
            With pPage.Response
                .ClearContent()
                .ClearHeaders()
                Select Case PexportType
                    Case ExportType.PDF
                        .ContentType = "application/pdf"
                        '.AddHeader("Content-Disposition", "inline; filename=Report.pdf")
                    Case ExportType.Excel
                        .ContentType = "application/vnd.ms-excel"
                        '.AddHeader("Content-Disposition", "inline; filename=Report.XLS")
                End Select
     
                .BinaryWrite(pReportStream.ToArray)
                .End()
            End With
        Catch ex As System.Exception
            Throw ex

        End Try
    End Sub

0
 
Brad Dobyns, CSMCommented:
And you are saying that when the Excel file is produced, it is an older version that is producedd and not, say, an Excel XP version?

Brad
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Brad Dobyns, CSMCommented:
Also, what browser are you using to open the excel file?

Brad
0
 
curtis591Author Commented:
I reboot and display the excel report. I get  a new one.  If I make changes and regenerate the report I still get the old one where anyone else would see the new one.  In my code I save it to file and load it.  If I go into excel and open the file it is the new one but in the browser it displays the old on.
0
 
Brad Dobyns, CSMCommented:
Not sure if this is the issue or not, but you code, the file or the browser may not be the issue. In order to view an Excel file with the least complications, you should use IE 4.01 or better, AND Microsoft Office Web Components (OWC), which is included with most versions of Office 2000 or bettter. Versions of Office 2000 or better need to be installed on your system in order to work. Now here is the catch...

If you have Excel 2000 installed on your system, check your version of the software. And this just figures but for reasons known only to MS, the Office Web Components are NOT included with the Small Business Edition of Office 2000 or with the stand-alone version of Excel 2000. According to MS, you can "legally" install the Office Web Components if you own Office 2000 Small Business Edition AND if someone in your organization has a license for Microsoft Office 2000 Premium, Professional, or Standard, or Microsoft Access 2000. If you have only the stand-alone version of Excel, you cannot install the Web Components. Since I assume you are running it on a server for this application, you may need to check the version installed on the server if indeed do have Office installed on the server.

Sounds like things MS would do just to mess us up...

Brad
0
 
Brad Dobyns, CSMCommented:
And what browser are you using?

Brad
0
 
curtis591Author Commented:
IE 6
0
 
Brad Dobyns, CSMCommented:
Since you are using .NET, what happens if you use this:

.ContentType = "application/x-msexcel"

instead of this:

Response.ContentType = "application/vnd.ms-excel"

Brad
0
 
curtis591Author Commented:
Brad,
  Did not work.  I am moved this to a production server to see if what something with my Web Server.  Once Again PDF work fines and the Excel from Crystal Reports does not.  I am the only one that is experiencing this as I have numerous other developers try and they can do Excel and PDF with no problems.
0
 
Brad Dobyns, CSMCommented:
If it is only you that is having the problem and no other developer, I would suggest checking the settings on the other user's browsers. It could be as simple as a setting that is causing the problem. For all that I have mentioned and found out, I know of no good reason why you alone should be experiencing the problem and no on else. However, if it works for everyone else and not you, does it matter that much? The fact is that it DOES work. :o)

Brad
0
 
Brad Dobyns, CSMCommented:
I have read in places where you can target the version of excel when you output and stream from Crystal Reports to Excel but that is not what you are doing. So that is even more confusing...

Brad
0
 
curtis591Author Commented:
Most Time it would be ok if I was the only one it did not work for but these is one of those wonderful Sarbanes Oxley systems that IT is using to track changes.
0
 
sciber_dudeCommented:
dont know how to solve this. but it looks like a caching issue.

:) SD
0
 
curtis591Author Commented:
I notice that When I veiw the excel file in the web it opens excel on my PC.  When I close IE Excel does not close yet it does on other users computers.
0
 
Brad Dobyns, CSMCommented:
Hmmmmmmm, sounds like a IE is not opening the excel client within the browser. See if this helps in checking your settings since this is what is happening to you:

http://support.microsoft.com/default.aspx?scid=kb;en-us;162059

Just do the opposite. :o)

Brad
0
 
Brad Dobyns, CSMCommented:
0
 
curtis591Author Commented:
In the file types menu I uncheck Browse In Same window and it has resolved the problem.  Doesn't explain why this was happening but its good enough me.  It's little problems like this that drive me nuts when you waste 3/4 of a day on them.
0
 
Brad Dobyns, CSMCommented:
Glad I could help. Thanks for the points. :o)

Brad
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 11
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now