Exporting crystal report to excel problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sep410
    New Member
    • Jul 2008
    • 77

    #1

    Exporting crystal report to excel problem

    Hi all,
    I have a report in crystal report when I export it to excel each column will be shown in 2 or 3 merged columns!!!
    The worst part is that sometimes the header of the column is in the A and B columns but the details of this columns are in B and C in excel sheet!!!
    I don’t want that and I want to have normal excel sheet with the boarders around each cell what should I do?
    Here is the example of my exported report in excel:
    Code:
    A		B		C		D		E		F	      G	
    Case 		Customer Name							     Tel
    1						John				1232547
    2						Jane				9999999	
    3						Mark				99999544
    4						Harry				8789874
    
    What I need in excel is:
    A	B		C		
    Case 	Customer Name 	Tel
    1	John		1232547
    2	Jane		9999999	
    3	Mark		99999544
    4	Harry		8789874
    Please help me.
  • dnnddane
    New Member
    • Sep 2008
    • 7

    #2
    I used to come across this problem before.
    What i have done is to rearrange all fields in crystall report and make sure header and value field is in the same column(same position, width and height).
    you can use snap to grid in Crystal Report to help you in arranging fields.

    Finally, you will get a good result in excel file.
    Dane

    Comment

    • amwggyy504
      New Member
      • Sep 2008
      • 5

      #3
      I exploitation report use VS2005 RDLC,it Export to excel is very good .

      Comment

      • grigorythegreat
        New Member
        • Sep 2008
        • 1

        #4
        There is no need to involve Crystal Reports if all you want is to export your data into an excel spreadsheet. Below is the code that worked for me:

        Private Sub ExportToExcel(B yVal GridView1 As GridView)

        Try
        Dim strFileName As String = "Report" & ".xls"
        Dim strFilePath As String = "C:\temp\" & strFileName
        If File.Exists(str FilePath) Then
        File.Delete(str FilePath)
        End If

        Dim oStringWriter As New StringWriter
        Dim oHtmlTextWriter As New HtmlTextWriter( oStringWriter)
        Dim objStreamWriter As StreamWriter
        Dim strStyle As String = Environment.New Line

        objStreamWriter = File.AppendText (strFilePath)
        GridView1.Rende rControl(oHtmlT extWriter)
        objStreamWriter .WriteLine(strS tyle)
        objStreamWriter .WriteLine(oStr ingWriter.ToStr ing)
        objStreamWriter .Close()
        Me.btnExportToE xcel.Attributes .Add("OnClick", "wOpen()")

        Catch ex As Exception

        End Try
        End Sub

        Comment

        • Sep410
          New Member
          • Jul 2008
          • 77

          #5
          Originally posted by dnnddane
          I used to come across this problem before.
          What i have done is to rearrange all fields in crystall report and make sure header and value field is in the same column(same position, width and height).
          you can use snap to grid in Crystal Report to help you in arranging fields.

          Finally, you will get a good result in excel file.
          Dane

          Thanks,
          That was what I needed.
          It is working well now.

          Comment

          Working...