Комментарии:
Someone explain me that for loop😭
ОтветитьThe best thanks!
Ответитьif you get an error do not forget to type the Value as Value?.
the whole code looks like this:
if(dataGridView1.Rows.Count > 0)
{
Excel.Application excelApp = new Excel.Application();
excelApp.Application.Workbooks.Add(Type.Missing);
for(int i=1; i < dataGridView1.Columns.Count + 1; i++)
{
excelApp.Cells[1, i] = dataGridView1.Columns[i - 1].HeaderText;
}
for(int i=0; i < dataGridView1.Rows.Count; i++)
{
for(int j=0; j < dataGridView1.Columns.Count; j++)
{
excelApp.Cells[i + 2, j + 1] = dataGridView1.Rows[i].Cells[j].Value?.ToString();
}
}
excelApp.Columns.AutoFit();
excelApp.Visible = true;
}
thank you very much
Ответитьhello I did all what you do , but i get message said "Object reference not set to an instance of an object. " in the line code : xcelApp.Cells[i + 2 , j + 1] = dataGridView1.Rows[i].Cells[j].Value.ToString();
could any one helps me please
Thank you so much
ОтветитьHello, can you help to write data to excel file template?
Ответитьthank you so much
Ответитьwhat happen if client doesnt have excel?
ОтветитьI'm not able to download DLL file
ОтветитьKindy tell how to save pictures in database and how to publish winforms applications
Ответитьgreat
Ответитьdear sir do you iam doing the same code but the out is out of order
ОтветитьHello! Thank you, it's cool! Can You be so kind to make a tutorial on how to export data from a form to a googlesheet? It'd be great!
ОтветитьIt wouldn't work if there is a combox inside the DG
ОтветитьThank you so much
Ответитьsir help. i have followed every code you did but im still getting error
System.NullReferenceException: 'Object reference not set to an instance of an object.'
the error im getting is at the
Excelapp.Cells[i + 2, j + 1] = dataGridView1.Rows[i].Cells[j].Value.ToString();
i have a System.NullReferenceException: 'Object reference not set to an instance of an object.'
can you fix it for me ? please, thank you
Sir, I'm stuck. Please help. I didn't find the Rows. Count in my case. It's showing the wavy red line. So how do I traverse through each row?
Ответитьthank you very very very very very very very very very very very very very very very very much
Ответить