Toggle theme
kamil.orchia.pl
Narzędzia użytkownika
Toggle theme
Zaloguj
Narzędzia witryny
Szukaj
Narzędzia
Pokaż stronę
Poprzednie wersje
Export to PDF
Odnośniki
Ostatnie zmiany
Menadżer multimediów
Indeks
Zaloguj
>
Ostatnie zmiany
Menadżer multimediów
Indeks
Ślad:
c-sharp-datagridtocsv
Ta strona jest tylko do odczytu. Możesz wyświetlić źródła tej strony ale nie możesz ich zmienić.
===== C Sharp - DataGrid to CSV ===== Klasa: <file> using System; using System.Text; using System.IO; using System.Windows.Forms; namespace adm { class exportCsv { protected System.Windows.Forms.DataGridView tabela; public exportCsv(System.Windows.Forms.DataGridView tabelap) { tabela = tabelap; } public void exportToCSV(string plik) { string temp = ""; Encoding e = Encoding.GetEncoding(1250); FileStream fs = new FileStream(plik, FileMode.Create); StreamWriter fsZapis = new StreamWriter(fs, e); for (int x = 0; x < tabela.ColumnCount; x++) temp = temp + tabela.Columns[x].HeaderText + ";"; fsZapis.WriteLine(temp); for (int y = 0; y < tabela.RowCount; y++) { temp = ""; for (int x = 0; x < tabela.ColumnCount; x++) temp = temp + tabela.Rows[y].Cells[x].Value.ToString() + ";"; fsZapis.WriteLine(temp); } fsZapis.Close(); } } } </file> Zastosowanie: <file> exportCsv eksportuj = new exportCsv(tabSprzetu); saveFileDialog1.ShowDialog(); eksportuj.exportToCSV(saveFileDialog1.FileName); </file>
c-sharp-datagridtocsv.txt
· ostatnio zmienione: 2018/07/16 11:47 przez
127.0.0.1
Narzędzia strony
Pokaż stronę
Poprzednie wersje
Odnośniki
Export to PDF
Do góry