CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual Basic Programming > Crystal Reports
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old March 23rd, 2005, 08:51 AM
    mrmartin1 mrmartin1 is offline
    Junior Member
     
    Join Date: Oct 2004
    Posts: 4
    mrmartin1 is an unknown quantity at this point (<10)
    Question Export to text file - format error

    Hi,

    I am using CrR 9.0 that is IS5 compatible in a Unix / Linux system. I am calling a CR report I have written and exporting results (via asp) to disk / text file.

    Set CrystalExportOptions = Session("oRpt").ExportOptions
    ExportFileName = "Calling_Matrix.txt"
    Path = Request.ServerVariables("PATH_TRANSLATED")

    While (Right(Path, 1) <> "\" And Len(Path) <> 0)
    iLen = Len(Path) - 1
    Path = Left(Path, iLen)
    Wend

    ExportDirectory = Path

    ExportType = "8"
    CrystalExportOptions.DiskFileName = ExportDirectory & ExportFileName
    CrystalExportOptions.FormatType = CInt(ExportType)
    CrystalExportOptions.DestinationType = CInt(1)
    Session("oRpt").Export False

    This works ok - but when I examine the file - I am receiving unwanted carriage returns (at least I think that is what they are) at the end of each line - resulting in the following line haveing a space on the left side (see below). Below is the code that then puts the data into a fixed format text file. Any ideas??

    Private Sub DownloadFile(file)

    Dim strAbsFile
    Dim strFileExtension
    Dim objFSO
    Dim objFile
    Dim objStream

    strAbsFile = Server.MapPath(file)

    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

    If objFSO.FileExists(strAbsFile) Then
    Set objFile = objFSO.GetFile(strAbsFile)

    Response.Clear

    Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name
    Response.AddHeader "Content-Length", objFile.Size
    Response.ContentType = "application/octet-stream"
    Set objStream = Server.CreateObject("ADODB.Stream")
    objStream.Open

    objStream.Type = 1
    Response.CharSet = "UTF-8"

    objStream.LoadFromFile(strAbsFile)

    Response.BinaryWrite(objStream.Read)
    objStream.Close
    Set objStream = Nothing
    Set objFile = Nothing
    Else
    Response.Clear
    Response.Write("No such file exists.")
    End If
    Set objFSO = Nothing
    End Sub

    Oops - I almost forgot - a valid file was produced before our company switched from windows2000 to windows2003.

    Thanks in Advance!!!

    Mike

    Last edited by mrmartin1; March 24th, 2005 at 08:28 AM.
    Reply With Quote
      #2    
    Old April 8th, 2005, 06:29 AM
    kbbiju kbbiju is offline
    Junior Member
     
    Join Date: Apr 2005
    Posts: 1
    kbbiju is an unknown quantity at this point (<10)
    Re: Export to text file - format error

    Hi..

    I am also facing the same problem. In my project I wanted to export Crystal report t a text file. But to my surprise after export the alignment was totally collapsed.

    After a lot of googling I came to understand that text alignment is not possible . Crystal report is aligning the report to the maximum limit it can. The alignmrnt problem will be comming only for text format. If U r opening the file in Word pad or rtf the content will be aligned properly.

    the below link explains the same
    http://www.sourcecodesworld.com/faqs...eports-faq.asp

    Hope this information is helpful to U..If U got any method to solve pls tell me.

    With regards Biju.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual Basic Programming > Crystal Reports


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 07:10 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009