Error in saving variables from .txt file to Excel sheet

Hello,
I have problems in saving strings extracted from a .txt file in an Excel File.
For example in the .txt file there is a text:
Immatricolazione

6 / 2006

I saved the value 6/2006 in a string variable called Immatricolazione, using regular expressions.


Since there where some empty spaces in the string I manipulated it with the String.Join option.

When I save the variable in the Excel file it inserts a date in the cell giu-2016 and not the value extracted.

I also tried to convert the string to a DateTime and then back to a string


but it didn’t work.
Can anyone kindly help me in solving the problem?
Thank you so much.
Camilla.

Hi Camilla,

Excel is interpreting that string as a Date value. You can prevent this by having an apostrophe (‘) before you enter a number, eg. '1 / 2016
Check this article on how to prevent excel to automatically changing numbers to dates.

Regards
Silviu

3 Likes

Thank you so much @Silviu, it solved my problem.
Now I get the correct string inside the Excel File.
Thank you so much for your help.
Camilla.

Hi CamiCat!

I am currently working on a project and trying to convert a txt file into Excel (just like how u did) into different columns.

How did you do it? Could you share your XAML file? :slight_smile:

Thanks!!

Avene

1 Like