cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Exporting Crystal report into Excel with code

former_member1012208
Participant
0 Likes
1,130

I have written the following code to export crysal reports to excel. My problem is, when it exports number it adds the thousand seperator (,), but if I export the report from Crystal designer, it works fine. So I believe I am missing something in my code. Could some one help me with this? Any help is greatly appreciated.


       Dim xlApp As Microsoft.Office.Interop.Excel.Application
        Dim xlBook As Workbook


        Dim myReport1 As New ReportDocument
        Dim reportPath1 As String = ""

        reportPath1 = "C:\test\su.rpt"
        myReport1 = New ReportDocument
        myReport1.Load(reportPath1)

        Dim tmpExcelFile As String = ""

        tmpExcelFile = "C:\test\test.xls"

        myReport1.ExportToDisk(ExportFormatType.Excel, tmpExcelFile)

Accepted Solutions (1)

Accepted Solutions (1)

former_member188030
Active Contributor
0 Likes

Hi Don,

Please provide

- Crystal Reprots version

- Visual Studio version

- Win or web app?

Try using 'ExportToStream' see if it reproduces the issue.

[1198587 - How to export a report to stream in C Sharp (C#) for Visual Studio .NET |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333133393338333533383337%7D.do]

- Bhushan.

Answers (2)

Answers (2)

former_member1012208
Participant
0 Likes

-

0 Likes

Hi Don,

What happens if you export from the Viewer?

How do you have the fields defined in your report for the number format?

Don

former_member1012208
Participant
0 Likes

Exporting from the viewer direct works fine. I have formatted all numbers and currency fields not to show thousand separator, but til it didn't work.

So I used the totext(x,y,z) function to convert all numbers and currency to text and that worked. Still I would like to know how to do this without totext function.

I have Crystal reports 2008 with VS 2010

0 Likes

Hi Don,

All I did was open the report up and set the field to a format without the thousand separator. I did not use Custom option but one of the defaults and it works fine for me.

Thanks

Don

former_member1012208
Participant
0 Likes

It doesn't work for me. Only option is to use totext(x,y,z)

0 Likes

Hi Don,

Can you duplicate it if you use CR for VS 2010 or use VS 2008 with CR 2008 runtime? We don't support CR 2008 in VS 2010.

Go to this page to get the free CR for VS 2010 plug-in, it is full featured and gives you inProc RAS also...

http://www.sdn.sap.com/irj/boc/crystalreports-dotnet

Bottom of the page to get the installer and runtime.

Don