473,395 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.ReportDocum ent
Imports CrystalDecisions.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Dim BeginPeriode As Date
Dim EindPeriode As Date

BeginPeriode = Session("BeginPeriode")
EindPeriode = Session("EindPeriode")

Dim myReport As New _Rapport_KO_ZonderContract

Dim myParameterFields As New ParameterFields
Dim myParameterField As New ParameterField
Dim myRangeValues As New ParameterRangeValue
Dim myRangeValue As New ParameterRangeValue
myParameterField.ParameterFieldName = "Periode"
myRangeValue.StartValue = BeginPeriode
myRangeValue.EndValue = EindPeriode

myReport.SetParameterValue("Periode", myRangeValue)

crViewer.ReportSource = myReport
'export to pdf
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myExportFile As String

myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
Session.SessionID.ToString & ".pdf"
myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestinationOptions.DiskFileName = myExportFile
myExportOptions = myReport.ExportOptions
With myExportOptions
.DestinationOptions = myDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With

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

Session("exportbestand") = myExportFile

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

"Alison Givens" <in**@cross-it.nl> wrote in message
news:Om**************@TK2MSFTNGP03.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 CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.ReportDocum ent
Imports CrystalDecisions.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Dim BeginPeriode As Date
Dim EindPeriode As Date

BeginPeriode = Session("BeginPeriode")
EindPeriode = Session("EindPeriode")

Dim myReport As New _Rapport_KO_ZonderContract

Dim myParameterFields As New ParameterFields
Dim myParameterField As New ParameterField
Dim myRangeValues As New ParameterRangeValue
Dim myRangeValue As New ParameterRangeValue
myParameterField.ParameterFieldName = "Periode"
myRangeValue.StartValue = BeginPeriode
myRangeValue.EndValue = EindPeriode

myReport.SetParameterValue("Periode", myRangeValue)

crViewer.ReportSource = myReport
'export to pdf
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myExportFile As String

myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
Session.SessionID.ToString & ".pdf"
myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestinationOptions.DiskFileName = myExportFile
myExportOptions = myReport.ExportOptions
With myExportOptions
.DestinationOptions = myDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With

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

Session("exportbestand") = myExportFile

End Sub
Kind regards,
Alison

Jun 15 '06 #2
Hi Alison,

myExportFile = exportPath & "myExcel.xls"
Instead of ExportFormatType.PortableDocFormat use ExportFormatType.Excel

Sanjib

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

"Alison Givens" <in**@cross-it.nl> wrote in message
news:Om**************@TK2MSFTNGP03.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 CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.ReportDocum ent
Imports CrystalDecisions.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Dim BeginPeriode As Date
Dim EindPeriode As Date

BeginPeriode = Session("BeginPeriode")
EindPeriode = Session("EindPeriode")

Dim myReport As New _Rapport_KO_ZonderContract

Dim myParameterFields As New ParameterFields
Dim myParameterField As New ParameterField
Dim myRangeValues As New ParameterRangeValue
Dim myRangeValue As New ParameterRangeValue
myParameterField.ParameterFieldName = "Periode"
myRangeValue.StartValue = BeginPeriode
myRangeValue.EndValue = EindPeriode

myReport.SetParameterValue("Periode", myRangeValue)

crViewer.ReportSource = myReport
'export to pdf
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myExportFile As String

myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
Session.SessionID.ToString & ".pdf"
myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestinationOptions.DiskFileName = myExportFile
myExportOptions = myReport.ExportOptions
With myExportOptions
.DestinationOptions = myDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With

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

Session("exportbestand") = 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.EventArgs) Handles cmdPrint.Click
Response.ClearContent()
Response.ClearHeaders()
'Response.ContentType = "application/pdf"
Response.ContentType = "application/xls"

Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

Response.WriteFile(myExportFile)
Response.Flush()
Response.Close()

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

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

Alison.


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

myExportFile = exportPath & "myExcel.xls"
Instead of ExportFormatType.PortableDocFormat use ExportFormatType.Excel

Sanjib

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

"Alison Givens" <in**@cross-it.nl> wrote in message
news:Om**************@TK2MSFTNGP03.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 CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.ReportDocum ent
Imports CrystalDecisions.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Dim BeginPeriode As Date
Dim EindPeriode As Date

BeginPeriode = Session("BeginPeriode")
EindPeriode = Session("EindPeriode")

Dim myReport As New _Rapport_KO_ZonderContract

Dim myParameterFields As New ParameterFields
Dim myParameterField As New ParameterField
Dim myRangeValues As New ParameterRangeValue
Dim myRangeValue As New ParameterRangeValue
myParameterField.ParameterFieldName = "Periode"
myRangeValue.StartValue = BeginPeriode
myRangeValue.EndValue = EindPeriode

myReport.SetParameterValue("Periode", myRangeValue)

crViewer.ReportSource = myReport
'export to pdf
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myExportFile As String

myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
Session.SessionID.ToString & ".pdf"
myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestinationOptions.DiskFileName = myExportFile
myExportOptions = myReport.ExportOptions
With myExportOptions
.DestinationOptions = myDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With

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

Session("exportbestand") = 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
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...
2
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 =...
3
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...
2
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...
1
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.