Good afternoon I am trying to read an excel file with entity framework, I have a class which I want to be filled with the data from the excel file and at the end show me the excel in a datagrid c #. What is the way to do it? xfavor
private void btnAbrir_Click(object sender, EventArgs e)
{
using (OpenFileDialog doc = new OpenFileDialog() { Filter = "Microsoft Excel (*.xlsx)|*.xlsx|Todos los archivos (*.*)|*.*", ValidateNames = true })
{
if (doc.ShowDialog() == DialogResult.OK)
{
StreamReader fs = File.OpenText(doc.FileName);
string s;
while (!fs.EndOfStream)
{
s = fs.ReadLine();
dataGridView1.Rows.Add(s); //Aqui me genera error ya que me dice que primero debe agregar columnas
}
fs.Close();
}
}