From 4089695727357d5e41ff0e4d39f416ff2ffee926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B8=D1=82=D0=B0=D0=BD?= Date: Fri, 28 Oct 2022 00:01:26 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Forms/MainForm.cs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Forms/MainForm.cs b/Forms/MainForm.cs index d7ffa7c..3d0940d 100644 --- a/Forms/MainForm.cs +++ b/Forms/MainForm.cs @@ -16,7 +16,7 @@ public partial class MainForm : Form public MainForm() { - //CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; InitializeComponent(); btnCalculateAll.Enabled = false; btnSave.Enabled = false; @@ -380,26 +380,25 @@ void SaveFile(string Path) { try { - using (var sw = new StreamWriter(Path,true)) + using var sw = new StreamWriter(Path,false); + for (int i = 0; i < dgv1.Columns.Count; i++) //: Заголовки столбцов { - for (int i = 0; i < dgv1.Columns.Count; i++) //: Заголовки столбцов - { - sw.Write(dgv1.Columns[i].HeaderText + (i== dgv1.Columns.Count-1? "": '\t')); - } + sw.Write(dgv1.Columns[i].HeaderText + (i== dgv1.Columns.Count-1? "": '\t')); + } - sw.WriteLine(); + sw.WriteLine(); - for (int i = 0; i < dgv1.Rows.Count; i++) + for (int i = 0; i < dgv1.Rows.Count; i++) + { + sw.Write(dgv1.Rows[i].HeaderCell.Value.ToString() + '\t'); //: Заголовок строки + for (int j = 0; j < dgv1.Rows[i].Cells.Count; j++) { - sw.Write(dgv1.Rows[i].HeaderCell.Value.ToString() + '\t'); //: Заголовок строки - for (int j = 0; j < dgv1.Rows[i].Cells.Count; j++) - { - var value = dgv1.Rows[i].Cells[j].Value; - sw.Write(value is double d? d.ToString() : value.ToString() + (j==dgv1.Rows[i].Cells.Count-1? '\n':'\t')); //: Значение ячейки - } //TODO: Модифицировать ToStringT(), чтобы гарантировано записывал только точки - } + var value = dgv1.Rows[i].Cells[j].Value; + sw.Write((value is double d? d.ToString(CultureInfo.InvariantCulture) : value.ToString()) + (j==dgv1.Rows[i].Cells.Count-1? '\n':'\t')); //: Значение ячейки + } //TODO: Модифицировать ToStringT(), чтобы гарантировано записывал только точки + } - /*foreach (DataGridViewRow row in dgv1.Rows) + /*foreach (DataGridViewRow row in dgv1.Rows) { foreach (DataGridViewCell cell in row.Cells) { @@ -407,7 +406,6 @@ void SaveFile(string Path) } sw.WriteLine('\n'); }*/ - } } catch (Exception e) {