private void saveToolStripMenuItem_Click(object sender, EventArgs e) { Stream myStream; string path = "Hostel.hls"; SaveFileDialog saveFileDialog1 = new SaveFileDialog { Filter = "Excel 97-2003 WorkBook|*.xls", FilterIndex = 2, RestoreDirectory = true }; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { if ((myStream = saveFileDialog1.OpenFile()) != null) { path = Path.GetFullPath(saveFileDialog1.FileName); myStream.Close(); } } DataSet ds = GenerateExcel.GenerateExcelFile(HostelRepository.GetHostels()); ExcelLibrary.DataSetHelper.CreateWorkbook(path, ds); MessageBox.Show("Файл сохранен успешно"); }
private void LoadGridData() { BindingSource binding = new BindingSource { DataSource = HostelRepository.GetHostels() }; HostelDataGridView.DataSource = binding; }