- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
private void button8_Click(object sender, EventArgs e)
{
string fn = "";
string st = "";
string value = "";
string dirfile = "";
StreamWriter sw;
if (textBox1.Text != "")
{
dirfile = textBox1.Text + "\\" + GetFileName(openFileDialog1.FileName) + comboBox1.SelectedValue.ToString() + ".csv";
sw = new StreamWriter(dirfile, false, System.Text.Encoding.UTF8);
}
else
{
sw = new StreamWriter(openFileDialog1.FileName + comboBox1.SelectedValue.ToString() + ".csv", false, System.Text.Encoding.UTF8);
}
// Создаем колонки
for (int cl = 0; cl < dt.Columns.Count; cl++)
{
fn = dt.Columns[cl].ColumnName;
if (cl == 0)
{
st = fn.Replace("\n", "").Replace(";", "");
}
else
{
st += ";" + fn.Replace("\n", "").Replace(";", "");
}
}
sw.WriteLine(st);
progressBar1.Minimum = 1;
progressBar1.Maximum = dt.Rows.Count;
for (int i = 0; i < dt.Rows.Count; i++)
{
progressBar1.Value = i + 1;
Application.DoEvents();
for (int j = 0; j < dt.Columns.Count; j++)
{
value = dt.Rows[i][j].ToString();
if (value == "") { value = " "; }
try
{
Convert.ToInt16(value);
if (j == 0)
{
st = value.Replace("\n", "").Replace(";", "");
}
else
{
st += ";" + value.Replace("\n", "").Replace(";", "");
}
}
catch (System.FormatException exp)
{
if (j == 0)
{
st = value.Replace("\n", "").Replace(";", "");
}
else
{
st += ";" + value.Replace("\n", "").Replace(";", "") ;
}
}
catch (OverflowException oe)
{
if (j == 0)
{
st = value.Replace("\n", "").Replace(";", "");
}
else
{
st += ";" + value.Replace("\n", "").Replace(";", "");
}
}
}
sw.WriteLine(st);
}
sw.Close();
MessageBox.Show("Ok");
booratihno 11.03.2021 12:46 # +1
>button8_Click
Тебе в наследство досталось переделывать чью-то лабу?