Example #1
0
        private void Resultados2Excel(String ruta , String titulo)
        {
            DataGridViewRowCollection Seleccionados = dgvResultados.Rows;            
            GenExcell excel = new GenExcell(ruta, titulo);

            int j = 0;
            String[] cols = new String[dgvResultados.Columns.Count];
            foreach (DataGridViewColumn column in dgvResultados.Columns)
            {
                //DataGridViewColumnHeaderCell headerCell = column.HeaderCell;
                //string headerCaptionText = column.HeaderText;
                //string columnName = column.Name; // Used as a key to myDataGridView.Columns['key_name'];
                cols[j] = column.Name;
                j++;
            }
            excel.EscribeHeadersColumns(cols);

            foreach (DataGridViewRow item in Seleccionados)
            {
                if (! item.IsNewRow)
                { 
                String[] fila;
                fila = new String[item.Cells.Count];

                for (int i = 0; i < item.Cells.Count; i++)
                {
                    //fila[i] = i.ToString();                    
                    fila[i] = item.Cells[i].Value.ToString();
                }
                excel.EscribeLineaStringArray(fila);
             }
            }
            excel.Finalizar();
            Console.WriteLine("FIN");
        }
Example #2
0
 private void button9_Click(object sender, EventArgs e)
 {
     DataGridViewSelectedRowCollection Seleccionados = dataGridView1.SelectedRows;
     Console.WriteLine("INICIO");
     Console.WriteLine("COUNT: " + Seleccionados.Count);
     GenExcell excel = new GenExcell("file.html", "Lista de competiciones");
     //excel.DoExcellPrueba("file.xls");
     foreach (DataGridViewRow item in Seleccionados)
     {
         //string id = item.Cells[0].Value.ToString();
         //  Console.WriteLine(item.Cells[0].Value.ToString() + " / " + item.Cells[1].Value.ToString());
         String[] names = new String[2] { item.Cells[0].Value.ToString(), item.Cells[1].Value.ToString()};
         excel.EscribeLineaStringArray(names);
     }
     excel.Finalizar();
     Console.WriteLine("FIN");
 }