?
Solved

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

Posted on 2009-05-04
1
Medium Priority
?
622 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

770 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