473,785 Members | 2,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export CR to Excel problem

Hi there,
I am using VB.NET2003 with CR.
I have a good working webform that exports the CR to pdf when I hit the
print button.
Now what I want is that it exports the CR to Excel instead of Pdf.
I have tried some options but it always goes wrong with the parameters.

Can anybody help me to modify my code that works for pdf so that it will
work for excel.
I really like it to be modified, so please no completely different solution
with the chance that it will not work for the parameters.
(When possible ofcourse)
This is the code:
Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
Dim BeginPeriode As Date
Dim EindPeriode As Date

BeginPeriode = Session("BeginP eriode")
EindPeriode = Session("EindPe riode")

Dim myReport As New _Rapport_KO_Zon derContract

Dim myParameterFiel ds As New ParameterFields
Dim myParameterFiel d As New ParameterField
Dim myRangeValues As New ParameterRangeV alue
Dim myRangeValue As New ParameterRangeV alue
myParameterFiel d.ParameterFiel dName = "Periode"
myRangeValue.St artValue = BeginPeriode
myRangeValue.En dValue = EindPeriode

myReport.SetPar ameterValue("Pe riode", myRangeValue)

crViewer.Report Source = myReport
'export to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile

End Sub
Kind regards,
Alison
Jun 9 '06 #1
3 1157
Nobody?

"Alison Givens" <in**@cross-it.nl> wrote in message
news:Om******** ******@TK2MSFTN GP03.phx.gbl...
Hi there,
I am using VB.NET2003 with CR.
I have a good working webform that exports the CR to pdf when I hit the
print button.
Now what I want is that it exports the CR to Excel instead of Pdf.
I have tried some options but it always goes wrong with the parameters.

Can anybody help me to modify my code that works for pdf so that it will
work for excel.
I really like it to be modified, so please no completely different
solution
with the chance that it will not work for the parameters.
(When possible ofcourse)
This is the code:
Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
Dim BeginPeriode As Date
Dim EindPeriode As Date

BeginPeriode = Session("BeginP eriode")
EindPeriode = Session("EindPe riode")

Dim myReport As New _Rapport_KO_Zon derContract

Dim myParameterFiel ds As New ParameterFields
Dim myParameterFiel d As New ParameterField
Dim myRangeValues As New ParameterRangeV alue
Dim myRangeValue As New ParameterRangeV alue
myParameterFiel d.ParameterFiel dName = "Periode"
myRangeValue.St artValue = BeginPeriode
myRangeValue.En dValue = EindPeriode

myReport.SetPar ameterValue("Pe riode", myRangeValue)

crViewer.Report Source = myReport
'export to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile

End Sub
Kind regards,
Alison

Jun 15 '06 #2
Hi Alison,

myExportFile = exportPath & "myExcel.xl s"
Instead of ExportFormatTyp e.PortableDocFo rmat use ExportFormatTyp e.Excel

Sanjib

"Alison Givens" <in**@cross-it.nl> wrote in message
news:eS******** ******@TK2MSFTN GP04.phx.gbl...
Nobody?

"Alison Givens" <in**@cross-it.nl> wrote in message
news:Om******** ******@TK2MSFTN GP03.phx.gbl...
Hi there,
I am using VB.NET2003 with CR.
I have a good working webform that exports the CR to pdf when I hit the
print button.
Now what I want is that it exports the CR to Excel instead of Pdf.
I have tried some options but it always goes wrong with the parameters.

Can anybody help me to modify my code that works for pdf so that it will
work for excel.
I really like it to be modified, so please no completely different
solution
with the chance that it will not work for the parameters.
(When possible ofcourse)
This is the code:
Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
Dim BeginPeriode As Date
Dim EindPeriode As Date

BeginPeriode = Session("BeginP eriode")
EindPeriode = Session("EindPe riode")

Dim myReport As New _Rapport_KO_Zon derContract

Dim myParameterFiel ds As New ParameterFields
Dim myParameterFiel d As New ParameterField
Dim myRangeValues As New ParameterRangeV alue
Dim myRangeValue As New ParameterRangeV alue
myParameterFiel d.ParameterFiel dName = "Periode"
myRangeValue.St artValue = BeginPeriode
myRangeValue.En dValue = EindPeriode

myReport.SetPar ameterValue("Pe riode", myRangeValue)

crViewer.Report Source = myReport
'export to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile

End Sub
Kind regards,
Alison


Jun 15 '06 #3
I tried that but that doesn't work.
Btw, I saw that I forgot to post the printbutton code.
This is it:
Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click
Response.ClearC ontent()
Response.ClearH eaders()
'Response.Conte ntType = "applicatio n/pdf"
Response.Conten tType = "applicatio n/xls"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)
End Sub

As you can see I also changed the Response.Conten tType but that doesn't do
the trick aswell.

Alison.


"Sanjib Biswas" <sa***********@ ieee.org> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi Alison,

myExportFile = exportPath & "myExcel.xl s"
Instead of ExportFormatTyp e.PortableDocFo rmat use ExportFormatTyp e.Excel

Sanjib

"Alison Givens" <in**@cross-it.nl> wrote in message
news:eS******** ******@TK2MSFTN GP04.phx.gbl...
Nobody?

"Alison Givens" <in**@cross-it.nl> wrote in message
news:Om******** ******@TK2MSFTN GP03.phx.gbl...
Hi there,
I am using VB.NET2003 with CR.
I have a good working webform that exports the CR to pdf when I hit the
print button.
Now what I want is that it exports the CR to Excel instead of Pdf.
I have tried some options but it always goes wrong with the parameters.

Can anybody help me to modify my code that works for pdf so that it will
work for excel.
I really like it to be modified, so please no completely different
solution
with the chance that it will not work for the parameters.
(When possible ofcourse)
This is the code:
Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
Dim BeginPeriode As Date
Dim EindPeriode As Date

BeginPeriode = Session("BeginP eriode")
EindPeriode = Session("EindPe riode")

Dim myReport As New _Rapport_KO_Zon derContract

Dim myParameterFiel ds As New ParameterFields
Dim myParameterFiel d As New ParameterField
Dim myRangeValues As New ParameterRangeV alue
Dim myRangeValue As New ParameterRangeV alue
myParameterFiel d.ParameterFiel dName = "Periode"
myRangeValue.St artValue = BeginPeriode
myRangeValue.En dValue = EindPeriode

myReport.SetPar ameterValue("Pe riode", myRangeValue)

crViewer.Report Source = myReport
'export to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile

End Sub
Kind regards,
Alison



Jun 16 '06 #4

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

Similar topics

2
3476
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...
2
3998
by: Siu | last post by:
Hi, I use the following code to export and import a file Excel from resp. into a Web page with the following code: //EXPORT Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.Charset = ""; this.EnableViewState = false;
3
2019
by: Marja Ribbers-de Vroed | last post by:
Hi, One of my clients has a strange problem with my webapplication which I think may be related to some firewall setting on his computer. On several screens in the application, it is possible to click on an icon to start an export of data to Excel. The click on the icon triggers a form submit (a post, not a get) to a blank page, thereby passing the SQL select statement to use for the Excel export. I've never had any problem reports...
2
6421
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the method.... it creates 6 sheets # region Namespaces using System;
1
2224
by: thesti | last post by:
hello, i've just tried importing data from an excel file to a table in SQL Server 2000. there are only 887 rows in the excel file, but after the import process. and i select * from the Dest_Table. i see there are 2341 records. and also for this, i have to remove the primary key constraint from the table, because if not, there will be errors telling the primary filed cannot be null. there's no empty/null value in the excel file. why...
0
9645
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
9480
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,...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9950
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
6740
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.