Crystal Export to csv puts info on same line w/ Headers

I have the code below to export to a csv file, the report has headers. When I export, it puts the headers and the data on the same line. What would I need to change other than not using headers in a csv file?

Dim exportOpts As New ExportOptions()
        Dim diskOpts As New DiskFileDestinationOptions()
        exportOpts = report1.ExportOptions
        exportOpts.ExportFormatType = ExportFormatType.CharacterSeparatedValues
        exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
        diskOpts.DiskFileName = "U:\ExakTimeJobs\" & JobNme.Text & ".csv"
        exportOpts.DestinationOptions = diskOpts
        report1.Export()
BKennedy2008Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
Unfortunately that is the only solution other than to write your own CSV export routine.

For some reason that is how Crystal produces a CSV.

mlmcc
James0628Commented:
How about exporting to Excel, and then exporting from there to a CSV file?  If that's practical, it might be the simplest solution.

 Or, if the report is only going to be exported, and you don't really care what it looks like when you view or print it, another option might be to use a plain text export, and create the CSV format yourself.  You could create a formula that converts the fields in your detail section into strings and concatenates them together.  Something like:

'"' + CStr ({field1}) + '","' + CStr ({field2}) + '","' + CStr ({field3}) + '","' + ... + CStr ({fieldN}) + '"'

 I'm using single-quotes to include double-quotes in the string (' " ' and ' "," ' -- but without the spaces).

 You can add format strings to the CStr functions, if necessary (eg. to add or remove decimal places from a number).  Of course any field that was already a string wouldn't need the CStr function.

 You'd put that formula in the detail section, instead of your fields.

 You'd use a similar formula in the page header section (or maybe report header) to format the headings:

'"heading 1","heading 2","heading3","heading 4", ... "heading N"'

 Export that to text, and you get a CSV formatted file.

 James

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
Save the rpt in Crystal with the desired csv export option of "isolate Group sections".
This is done by going to File, Report Export Options...
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

BKennedy2008Author Commented:
My goal was to export it to a folder automatically. then there is a program the company purchased that I cannot change that imports the csv file. Unfortuantely, they require headers to import into the correct fields. My only option would be to show the user a crystal viewer, then export to a folder as a csv file from crystal manually. This is a one month temp solution, but I thought if I could just program it to export autmatically to csv file with headers and details below the headers through crystal, I wouldn't have to go through that extra step of exporting manually.
James0628Commented:
Did you try Ido's suggestion?  My (older) version of CR doesn't seem to have that option, but it sounds promising.

 James
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
Did you follow my suggestion above?  Then, test the effect on the output from your program.
BKennedy2008Author Commented:
I will give it a shot, sounds promising. Thanks Ido. Will let you know
BKennedy2008Author Commented:
OutFreakingStanding! Kudos to that trick, James Works like a champ!
BKennedy2008Author Commented:
Works like a champ (2nd Option) '"' + CStr ({field1}) + '","' + CStr ({field2}) + '","' + CStr ({field3}) + '","' + ... + CStr ({fieldN}) + '"'
James0628Commented:
Glad to hear it.  FWIW, if you have the option that Ido mentioned, I would give it a try.  If it works, it would be a lot simpler.  Even if you don't need it now, you may have use for it later.

 James
BKennedy2008Author Commented:
Option 1, excel was not the solution, because that was manual process. Your second solution, adding the string's together in a formula with the commas works the same as if you were to export manually from a crystal using the iscolate option which I did not want to do since that was a manual process. Thanks Again
James0628Commented:
Yeah, manually creating the CSV format works.  But in post # 40691720, IdoMillet said that CR has some export options that you can change, and one of those will apparently change how the headers are handled in a CSV export.  I'm running an older version of CR that doesn't have those options, so I can't try it, but if your version does have those options, it might be worth giving that a try.  If it worked, you could have left the report the way it was, and changing that one option would have changed the CSV export to work the way that you wanted it to.

 James
BKennedy2008Author Commented:
No he meant it doing manually from a Crystal report viewer, exporting it using that option in a checkbox. There are no programitic options for exportOpts.ExportFormatType = ExportFormatType.CharacterSeparatedValues even with the latest version.
mlmccCommented:
Actually Ido meant to set the default for the export to CSV to that setting.

In CR2008
Click FILE --> EXPORT --> REPORT EXPORT OPTIONS
Choose SEPARATED VALUES (CSV)
Click OK
Choose the ISOLATE option you want
Click OK

Next time you export to CSV the report will remember those options.

mlmcc
James0628Commented:
Yeah, the idea seems to be that you change the CSV export option and save the report, and then all CSV exports from that report will work that way by default.

 James
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.