Böyle olmasını istiyorum;

Böyle oluyor;

| C# Excel Çıktısı | 5 Mesajlar | 1.268 Okunma | ||


        protected void gvCikti_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                //Burada sütunlara müdahale edebilirsin.
            }
        }
        protected void gvCikti_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                //Burada sütunlara müdahale edebilirsin.
            }
        }




        private void button1_Click(object sender, EventArgs e)
        {
            int sutun = 1;
            int satir = 1;
            Excel.Application ExcelApp = new Excel.Application();
            ExcelApp.Workbooks.Add();
            ExcelApp.Visible = true;
            ExcelApp.Worksheets[1].Activate();
            for (int j = 0; j < dataGridView1.Columns.Count; j++)
            {
                ExcelApp.Cells[satir, sutun + j].Value = dataGridView1.Columns[j].HeaderText;
                ExcelApp.Cells[satir, sutun + j].Font.Color = System.Drawing.Color.Black; //Yazı Rengi
                ExcelApp.Cells[satir, sutun + j].Interior.Color = System.Drawing.Color.LightGreen; //Arka Plan Rengi
                ExcelApp.Cells[satir, sutun + j].Font.Bold = true; //Yazı Bold
                ExcelApp.Cells[satir, sutun + j].Font.Size = 14; //Yazı Size
                ExcelApp.Cells[satir, sutun + j].ColumnWidth = 16; //Colon Genişliği
                
            }
            satir++;
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                for (int j = 0; j < dataGridView1.Columns.Count; j++)
                {
                    ExcelApp.Cells[satir + i, sutun + j].Value = dataGridView1[j, i].Value;
                }
            }
        }
    }