Skip to content

Commit

Permalink
Исправлено сохранение файла
Browse files Browse the repository at this point in the history
  • Loading branch information
TuTAH1 committed Oct 27, 2022
1 parent 3610220 commit 4089695
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -380,34 +380,32 @@ 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)
{
sw.WriteLine(cell.Value.ToString() + '\t');
}
sw.WriteLine('\n');
}*/
}
}
catch (Exception e)
{
Expand Down

0 comments on commit 4089695

Please sign in to comment.