1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
public sealed class ExportCSV
{
ExportCSV() { }
public static void Export(string[][] datas, string fileName)
{
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@fileName, false, System.Text.UnicodeEncoding.Unicode))
{
foreach (string[] line in datas)
{
sw.WriteLine(string.Join(";", line));
}
}
}
}
........
private void button1_Click(object sender, EventArgs e)
{
string[][] lines = new string[3][];
lines[0] = new string[5] {"A","Zù$â\"","E","R","T"};
lines[1] = new string[4] {"Q","S","D",";;;G"};
lines[2] = new string[5] {"L","C","","qsd.23","''J"};
try
{
ExportCSV.Export(lines, "c:\\test.csv");
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
} |
Partager