473,732 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CrystalReport.N ET exporting to Excel Problem

I have an ASP.NET website where I am showing off crystal reports to users by
exporting them to pdf format. Following is the code:
----------------
1 Private Sub ExportReport()
2 Dim oStream As System.IO.Memor yStream =
3 myReport.Export ToStream(
ExportFormatTyp e.PortableDocFo rmat)

4 Response.Clear( )
5 Response.Buffer () = True
6 Response.Conten tType = "applicatio n/pdf"
7 Try
8 Response.Binary Write(oStream.T oArray())
9 Catch err As Exception
10 Response.Write( "< BR >")
11 Response.Write( err.Message.ToS tring)
12 End Try
13 oStream.Close()
14 Response.End()
15 End Sub
-----------------------
This code working absolutely fine. But if I want to export the reports to
EXCEL format then I just need to change lines 3 and 6:

3 ==> myReport.Export ToStream(
ExportFormatTyp e.Excel)

6 ==> Response.Conten tType = "applicatio n/vnd.ms-excel"

After the above alterations the should work fine but it doesn't. I even
tried to export to MS Word but it didn't work as well. Following is the
explaination what actually happening:

So after user clicks View Report, what happening is the excel application
opens in the browser but showing no report just saying : "You are curently
not logged in.
Please Log in first!". This is kind of weird to me because this message only
comes when somebody tries to access my website's any page without Logging
In. So to find out whats going wrong I put a break point at Page_Init
procedure. So I step through each line and just after executing
Response.End() statement I found that the page loads itself and as result of
that it breaks again at Page_Init procedure. But as I am checking at the
begining whether user is logged in or not and apparently when this page gets
executed 2nd time, it doesn't have any session information thus resulting
"You are curently not logged in. Please Log in first!" message but displays
in the excel application opened in the browser. One more thing I also
observed that whenever I clicked to get the report, I always see a small
window appearing for very short period of time at the top left corner with a
progress bar stating "Transferin g...
http://localhost/webreadfile/report.aspx". I really don't know whats causing
this twice execution because it only happens when I try to export cystal
report to some MS Office format such as MS Excel.

I also tried to put trace on and there I also confirmed it that this page is
getting executed twice in case of exporting to Excel format. Exporting to
PDF works perfect.

I would really really appreciate your help.

thanks.

Nov 19 '05 #1
1 3165
Hi Mustufa,

I suppose you are using Office 2000 in client-side. I think there is a bug
in Office 2000 that causes IE cannot show Excel (or Word) file properly. In
my experience, you use 'attachment' to get exported office file:

Private Sub ExportReport()
Dim oStream As System.IO.Memor yStream =
myReport.Export ToStream(
ExportFormatTyp e.Excel)
Response.Clear( )
Response.AddHea der("content-disposition", "attachment ;
filename="expor ted.xls");
Response.Buffer () = True
Response.Conten tType = application/vnd.ms-excel"
Try
Response.Binary Write(oStream.T oArray())
Catch err As Exception
Response.Write( "< BR >")
Response.Write( err.Message.ToS tring)
End Try
oStream.Close()
Response.End()
End Sub

HTH

Elton Wang

"Mustufa Baig" wrote:
I have an ASP.NET website where I am showing off crystal reports to users by
exporting them to pdf format. Following is the code:
----------------
1 Private Sub ExportReport()
2 Dim oStream As System.IO.Memor yStream =
3 myReport.Export ToStream(
ExportFormatTyp e.PortableDocFo rmat)

4 Response.Clear( )
5 Response.Buffer () = True
6 Response.Conten tType = "applicatio n/pdf"
7 Try
8 Response.Binary Write(oStream.T oArray())
9 Catch err As Exception
10 Response.Write( "< BR >")
11 Response.Write( err.Message.ToS tring)
12 End Try
13 oStream.Close()
14 Response.End()
15 End Sub
-----------------------
This code working absolutely fine. But if I want to export the reports to
EXCEL format then I just need to change lines 3 and 6:

3 ==> myReport.Export ToStream(
ExportFormatTyp e.Excel)

6 ==> Response.Conten tType = "applicatio n/vnd.ms-excel"

After the above alterations the should work fine but it doesn't. I even
tried to export to MS Word but it didn't work as well. Following is the
explaination what actually happening:

So after user clicks View Report, what happening is the excel application
opens in the browser but showing no report just saying : "You are curently
not logged in.
Please Log in first!". This is kind of weird to me because this message only
comes when somebody tries to access my website's any page without Logging
In. So to find out whats going wrong I put a break point at Page_Init
procedure. So I step through each line and just after executing
Response.End() statement I found that the page loads itself and as result of
that it breaks again at Page_Init procedure. But as I am checking at the
begining whether user is logged in or not and apparently when this page gets
executed 2nd time, it doesn't have any session information thus resulting
"You are curently not logged in. Please Log in first!" message but displays
in the excel application opened in the browser. One more thing I also
observed that whenever I clicked to get the report, I always see a small
window appearing for very short period of time at the top left corner with a
progress bar stating "Transferin g...
http://localhost/webreadfile/report.aspx". I really don't know whats causing
this twice execution because it only happens when I try to export cystal
report to some MS Office format such as MS Excel.

I also tried to put trace on and there I also confirmed it that this page is
getting executed twice in case of exporting to Excel format. Exporting to
PDF works perfect.

I would really really appreciate your help.

thanks.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9245
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works only exporting to single worksheet. but i need to export data to multiple worksheets. it is very urgent to us. so please help me in code.
4
3949
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear" TEXT field that contains data such as 2000/01, 2001/02, etc. If I export a Query with this kind of data to Excel, it gives me the text value of this field; however, when I export a Report bound to this TEXT field, Excel gives me the values 36526,...
2
8012
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
2
3475
by: Regnab | last post by:
I've got my code working so that it'll count the number of columns in the table and move across (eg Range A-P and then range Q-W). Problem is when I get to the end of the single letters and get into AA etc. Have got an idea of how I could do it by using Chr() and having an ongoing counter which is divided by 26 when it goes past Z to work out location. However, I'd dearly like there to be an easier way. Any ideas? Another problem I'm...
0
1251
by: crjunk | last post by:
According to the help files: ----- Exporting Reports with the Export Button The Export button is located at the top left corner of the CrystalReportViewer toolbar. When users click the Export button, a dialog box prompts them for the export format. The Export button appears automatically unless you disable the viewer toolbar (in which case you can either prompt users for export options, or use code to export with specific options).
0
1096
by: David Dvali | last post by:
Hello. I have some strange problem and will be very thankful if anybody will help me to solve it. In my ASP.NET web form I have used CrystalReport to produce some report, now I want to export this report into PDF without saving any temporary file on server disk. I'm using such code: P.S. At moment when this code is running I already have "crReportDocument" created and assigned all required parameters to it.
0
1036
by: David Dvali | last post by:
Hello. I have some strange problem and will be very thankful if anybody will help me to solve it. In my ASP.NET web form I have used CrystalReport to produce some report, now I want to export this report into PDF without saving any temporary file on server disk. I'm using such code: P.S. At moment when this code is running I already have "crReportDocument" created and assigned all required parameters to it.
0
1277
by: David Dvali | last post by:
Hello. I'm exporting CrystalReport into some formats, whne I export to Excel or PDF it works fine, but when I export it in HTML it shows me the error: ---------------------------------------------------------------- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
2
3184
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to set this up so as to do it reliably and minimize overhead? There are currently no constraints on the destination table. Assume the user or some configuration specifies the database name, server name, and filename+fullpath. The server is SQL...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.