Example #1
0
        private void MenuExcel_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog GrabarArchivo = new SaveFileDialog();
                GrabarArchivo.Filter          = "Excel(xls)|*.xls";
                GrabarArchivo.Title           = "Exportar Excel";
                GrabarArchivo.DefaultExt      = "xls";
                GrabarArchivo.FileName        = "";
                GrabarArchivo.OverwritePrompt = true;
                GrabarArchivo.ShowDialog();

                if (GrabarArchivo.FileName != "")
                {
                    // Saves the Image via a FileStream created by the OpenFile method.
                    System.IO.FileStream fs =
                        (System.IO.FileStream)GrabarArchivo.OpenFile();
                    GridAgentes2.ExportToXls(fs, true);

                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                Log.EscribirLog(ex.Message);
                MessageBox.Show("Error al generar archivo Excel: ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void ListarAgentes()
        {
            var agentes = ClsAgente.ObtenerAgentes().ObjetoTransaccion as List <Agente>;

            GridAgentes2.DataSource = agentes;
            GridAgentes2.RefreshDataSource();
        }