Quantcast
Channel: C#nedir?com Forum
Viewing all articles
Browse latest Browse all 613

C# : C# EXCELE AKTARIMDA HATA

$
0
0
Author: keles11
Subject: C# EXCELE AKTARIMDA HATA
Posted: 20 Nisan 2020 at 12:06

           try
            {
                Microsoft.Office.Interop.Excel.Application uygulama = new Microsoft.Office.Interop.Excel.Application();
                uygulama.Visible = true;
                Microsoft.Office.Interop.Excel.Workbook kitap = uygulama.Workbooks.Add(System.Reflection.Missing.Value);
                Microsoft.Office.Interop.Excel.Worksheet sayfa1 = (Microsoft.Office.Interop.Excel.Worksheet)kitap.Sheets[1];
                for (int i = 1; i < dataGridView1.Columns.Count; i++)
                {
                    Microsoft.Office.Interop.Excel.Range alan = (Microsoft.Office.Interop.Excel.Range)sayfa1.Cells[1, i + 1];
                    alan.Value2 = dataGridView1.Columns.HeaderText;
                }
                for (int i = 1; i < dataGridView1.Columns.Count; i++)
                {
                    for (int j = 0; j < dataGridView1.Rows.Count; j++)
                    {
                        Microsoft.Office.Interop.Excel.Range alan = (Microsoft.Office.Interop.Excel.Range)sayfa1.Cells[j + 2, i + 1];
                        alan.Value2 = dataGridView1[i, j].Value;
                    }
                }
            }
            catch (Exception)
            {

                MessageBox.Show("AKTARMADA HATA OLUŞTU");
            }

Edited by keles11 - Yesterday at 12:07

Viewing all articles
Browse latest Browse all 613

Trending Articles