Comma-delimited file format?

  • Thread starter Thread starter Carl Mercier
  • Start date Start date
C

Carl Mercier

Hi!

I have written a little class in .NET to convert a DataTable or a
dataView to a comma-delimited text file. This file eventually gets
imported in Excel or Word.

Everything works great, I handled commas and quotes and Excel reads my
files correctly. I have one little problem, though... If a field in the
datatable has a carriage return in it, it gets written to the text file
(of course) and Excel things it's the start of a new record.

Is there a special character I can replace the CR with so Excel knows
that it is not a new record but a CR inside a field?

Thank you!

Carl
 
Carl,
Try replacing CRLF (hex OD OA) with just the line feed character (hex 0A).

William
 
William,

It didn't work unfortunately. Do you have any other idea?

Thanks!

Carl
 
Carl,

I'm using Excel from office XP and it did work for me. However, I would
expect it should work for all version of Excel. What you can do to get the
format of the file correct is to examine a CSV file that Excel creates
itself. Create an Excel sheet with a cell that has a carriage return in it,
(To do this use the ALT+Enter key combo while editing) and then in the SAVE
AS dialog box change the file type to CSV. Examine the file using a hex
editor.

Hope this helps,

William.
 
In
William Leung said:
... Create an Excel sheet with a cell that has a
carriage return in it, (To do this use the ALT+Enter key combo while
editing) and then in the SAVE AS dialog box change the file type to
CSV. Examine the file using a hex editor.

My strings were separated by OA, just as you suggested.
 
Back
Top