Solved

how to write special characters to an excel file in C#.Net

Posted on 2009-05-04
1
609 Views
Last Modified: 2012-05-06
I have a text which contains special Characters: "création des motifs"
I need to write this to an excel file. This is not being written correctly.
Can anyone please help...
StreamWriter objFSOFile = null;
string strData = null;
string strPath = null;
objFSOFile = CreateStatFile("PROD.CSV", ref strPath);
strTitle = "création des motifs";
PrintFile(ref objFSOFile, strTitle);
 
public static StreamWriter CreateStatFile(string strFile, ref string strPath)
{
       System.IO.StreamWriter createStatFileReturn = null;
       FileInfo objFSO = null;
        if (!(Directory.Exists(@"C\PROD_CI\")))
            {
                Directory.CreateDirectory(@"C\PROD_CI\");
            }
            strPath = @"C\PROD_CI\" + strFile;
            objFSO = new FileInfo(strPath);
            if (objFSO.Exists)
            {
                objFSO.Delete();
            }
             createStatFileReturn = objFSO.CreateText();
             objFSO = null;
              return createStatFileReturn;
}
 
public static void PrintFile(ref StreamWriter objFSOFile, string strData)
{
       objFSOFile.WriteLine(strData);
}

Open in new window

0
Comment
Question by:MPakeezah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
MPakeezah earned 0 total points
ID: 24295687
The solution is while creating the file itself, create it as encoding UTF8.
createStatFileReturn = new StreamWriter(objFSO.Create(), System.Text.Encoding.UTF8);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question