Пример #1
0
        public string PrintExcel(DataGridView membershipreportdataGridView, string filename)
        {
            string result = "Cancel Reporting";

            SaveFileDialog fdlg = new SaveFileDialog();
            fdlg.Title = "Select file";
            fdlg.Filter = "Excel(*.xls,*.xlsx)|*.xls;*.xlsx|All Files(*.*)|*.*";
            fdlg.FileName = filename;

            if (fdlg.ShowDialog() == DialogResult.OK)
            {
                ConvertToExcelReport aPrintUtility = new ConvertToExcelReport();
                result = aPrintUtility.ToCsV(membershipreportdataGridView, fdlg.FileName);

            }

            return result;
        }
Пример #2
0
 private void excelButton_Click(object sender, EventArgs e)
 {
     string filename = DateTime.Now.Ticks + "viewReport";
     ConvertToExcelReport aConvertToExcelReport=new ConvertToExcelReport();
     var dataGridViewColumn = dataGridView1.Columns["GuestBill"];
     if (dataGridViewColumn != null) dataGridViewColumn.Visible = false;
     string result = aConvertToExcelReport.PrintExcel(dataGridView1, filename);
     MessageBox.Show(result);
     if (dataGridViewColumn != null) dataGridViewColumn.Visible = true;
 }