SaveTextFile mothod with quotation marks in spread data

Posted by: maverick123 on 8 September 2017, 2:51 pm EST

  • Posted 8 September 2017, 2:51 pm EST

    Hello Farpoint,

    My application loads the spread data from
    text file. Firstly I was loading the file by reading it line by line and
    setting the text on spread. The resulting application seems very slow due to
    this loading process therefore I reviewed the file loading process and
    introduced loading thru “
    LoadTextFile” method . Moveover to preserve previous spread data I use to save it
    in memory thru
    “SaveTextFile” method and
    append with currently reading data. This implementation improved my loading process.

    Code snippet is as follows:

    SpreadData = DataFromSaveStr + newdata

    lDataStream = New

    TextFileFlags.Unformatted, Model.IncludeHeaders.None, Chr(13), vbTab, Nothing)



    But recently, we I tried to load a file
    containing some “”” (quotation marks) in file, things start getting messy i.e.
    on loading further data spread starting adding multiple “”” (quotation marks)
    on my spread data. On further investigation, I found that “
    method add multiple “”” (quotation marks) if the cell
    data contains any quotation.

    Please guide me in regard that I want my
    data to save as it is (without any extra character to be added).

     Please find the attached files (Demo Project and problem screens)

    Thanks & Regards,


  • Replied 8 September 2017, 2:51 pm EST


    I was able to replicate the issue at my end and it seems to be a bug. I have reported it to the development team, the bug number  for the same is #99923996. It would be fixed in the next maintenance release.


    Manpreet Kaur.

  • Replied 8 September 2017, 2:51 pm EST

    The spreadsheet is working as intended. By default, the spreadsheet uses quotation marks as the text delimiter. If a cell value is a string value that contains the text delimiter then the spreadsheet writes out the value by enclosing the value with a pair of text delimiters and replacing any text delimiters within the string with a pair of text delimiters (which is similar to how strings are written in the Visual Basic language). This is needed so that the spreadsheet can read the values back from the file. This is how Excel works.

    If the application wants the values written to the file with out any text delimiters then the application will need to choose a custom text delimiter such that the custom text delimiter is not found in any of the cell values. For example...

        fpSpread1.ActiveSheet.SaveTextFile("C:\\users\\bobby\\work\\temp\\junk.txt", TextFileFlags.Unformatted, IncludeHeaders.None, null, null, "|");

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels