login about faq

Hi Forum,

when creating a csv-file, how can I put a single double quote around a Value?

Output shoud be like this: "Text";23,5

When I use SetCell 0, 0, "Text" the result is Text;23,5

When I use SetCell 0, 0, Chr$(35) + "Text" + Chr$(35) the result is """Text""";23,5

Thanks Christian

asked Jan 02 at 07:46

ChristianB's gravatar image


I think Chilkat would have to add a feature for you to be able to always put double-quotes around values. If you have an active support subscription, then perhaps you could fire off a request via email.

A possible workaround would be to pass all of your text values with a different character that won't ever appear in your data (for example, Chr$(1)), then at the end replace all occurrences of that character with double quotes. Here's a simple VB6 example:

   Dim lo_Csv As New Chilkat_v9_5_0.ChilkatCsv

lo_Csv.SetCell 0, 0, Chr$(1) & "Test" & Chr$(1)
   lo_Csv.SetCell 0, 1, 123

Debug.Print Replace$(lo_Csv.SaveToString, Chr$(1), """")

If there's a chance that your data could include reserved characters (which would cause the library to automatically enclose the field value in double-quotes) then you will need to first test that the field value doesn't have a reserved character (and if so don't pad the value with the Chr$(1)).


answered Jan 04 at 16:02

jpbro's gravatar image

jpbro ♦

jbpro, thanks, that's it.

strTemp = Replace$(objCsv.SaveToString, Chr$(1), """") Call objCsv.LoadFromString(strTemp) objCsv.SaveFile ("E:Test.csv")

The LoadFromString doesn't remove the double quotes, output is exactly what i wanted. "Text 0";23,5


answered Jan 06 at 04:24

ChristianB's gravatar image


Try to use '"Text"'


answered Jan 04 at 12:25

Americo%20Belinha's gravatar image

Americo Belinha

Better explained:


tried it in vfp and it works.

(Jan 06 at 04:15) Americo Belinha

The library automatically inserts double-quotes as necessary if the passed string includes any reserved characters (double-quotes, newlines, delimiter character). If the passed string doesn't contain any reserved characters, then the double-quotes aren't needed around the resultant field value.

See the relevant portion of the documentation here:

SetCell(ByVal row As Long, ByVal col As Long, ByVal content As String) As Long

Sets the contents for a single cell in the CSV. The content may include any characters including CRLF's, double-quotes, and the delimiter character. The Save methods automatically double-quote fields with special chars when saving. The Load methods automatically parse double-quoted and/or escaped fields correctly when loading.

Returns 1 for success, 0 for failure.


answered Jan 04 at 15:04

jpbro's gravatar image

jpbro ♦

Thanks so far, but that doesen't help me.

I've read the documentation and I know that strings not containing special characters doesn't have to be quoted. But I have to "produce" a given format, the other side want's to have strings in double qoutes.

If there's no possibility to give out "normal" strings in double qoutes, I cannot use the library.


answered Jan 04 at 15:41

ChristianB's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jan 02 at 07:46

Seen: 854 times

Last updated: Jan 06 at 04:24

powered by OSQA