F
Frank Bishop
I have some code that exports one of my reports to RTF. The problem I
have is that it does not append the RTF on to the exported file. If I do
this after the fact, it works fine. Help appreciated. Here is some of
the code I have been working with:
<code>
Dim ExportPath As String
ExportPath = Request.PhysicalApplicationPath + "Exported\"
If Directory.Exists(ExportPath) = False Then
Directory.CreateDirectory(Request.PhysicalApplicationPath +
"Exported\")
'Other Crystal Specific code in here....
Select Case DropDownList1.SelectedItem.Text 'this contains the value of
the selected export format.
Case "Rich Text (RTF)"
'------------------------------------------
'Export to RTF.
'append a filename to the export path and set this file
as the filename property for
'the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = ExportPath +
Session.SessionID.ToString + ".rtf"
'set the required report ExportOptions properties
With crReportDocument.ExportOptions
.ExportDestinationType =
ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.RichText
.DestinationOptions = crDiskFileDestinationOptions
End With
crReportDocument.Export()
DisplayDownloadDialogRTF()
'----------------------------------------------------------
Sub DisplayDownloadDialogRTF()
Dim objFileName As String
Dim MyFileInfo As FileInfo
Dim StartPos, FileSize As Long
objFileName = "c:\Web Applications\exported\" +
Session.SessionID.ToString + ".RTF"
MyFileInfo = New FileInfo(objFileName)
FileSize = MyFileInfo.Length
Response.Clear()
Response.ContentType = "application/RTF"
Response.AddHeader("Content-Disposition", "attachment;filename="
& objFileName)
Response.WriteFile(objFileName, StartPos, FileSize)
End Sub
'----------------------------------------------------------
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
ExportReport()
End Sub
</code>
have is that it does not append the RTF on to the exported file. If I do
this after the fact, it works fine. Help appreciated. Here is some of
the code I have been working with:
<code>
Dim ExportPath As String
ExportPath = Request.PhysicalApplicationPath + "Exported\"
If Directory.Exists(ExportPath) = False Then
Directory.CreateDirectory(Request.PhysicalApplicationPath +
"Exported\")
'Other Crystal Specific code in here....
Select Case DropDownList1.SelectedItem.Text 'this contains the value of
the selected export format.
Case "Rich Text (RTF)"
'------------------------------------------
'Export to RTF.
'append a filename to the export path and set this file
as the filename property for
'the DestinationOptions class
crDiskFileDestinationOptions.DiskFileName = ExportPath +
Session.SessionID.ToString + ".rtf"
'set the required report ExportOptions properties
With crReportDocument.ExportOptions
.ExportDestinationType =
ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.RichText
.DestinationOptions = crDiskFileDestinationOptions
End With
crReportDocument.Export()
DisplayDownloadDialogRTF()
'----------------------------------------------------------
Sub DisplayDownloadDialogRTF()
Dim objFileName As String
Dim MyFileInfo As FileInfo
Dim StartPos, FileSize As Long
objFileName = "c:\Web Applications\exported\" +
Session.SessionID.ToString + ".RTF"
MyFileInfo = New FileInfo(objFileName)
FileSize = MyFileInfo.Length
Response.Clear()
Response.ContentType = "application/RTF"
Response.AddHeader("Content-Disposition", "attachment;filename="
& objFileName)
Response.WriteFile(objFileName, StartPos, FileSize)
End Sub
'----------------------------------------------------------
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
ExportReport()
End Sub
</code>