0

Use OpenFileDialogwith EPPlus. I get a compile error of:

The name 'sheet' does not exist in the current context

Now, the obvious issue is how do I associate the selected Excel file with my EPPPlus & 2 what do I do to remove the error above?

using OfficeOpenXml;
using OfficeOpenXml.Drawing;

private void btn_ReadExcelToArray_Click(object sender, EventArgs e)
{
  fd.Filter = "Excel Files|*.xlsx";
  fd.InitialDirectory = @"C:\";
  if (fd.ShowDialog() == DialogResult.OK)
  {          
    var columnimport = sheet.Cells["A2:A"];
    foreach (var cell in columnimport)
    {
        var column1CellValue = cell.GetValue<string>();
    }
  }
}
Big Pimpin
  • 427
  • 9
  • 23
  • 1
    yes there is - but perhaps you will show us what you have tried so far? – Pilgerstorfer Franz Mar 25 '15 at 14:58
  • http://stackoverflow.com/questions/657131/how-to-read-data-of-an-excel-file-using-c – horHAY Mar 25 '15 at 14:58
  • Do you need to support both `.xls` and `.xlsx` files? – D Stanley Mar 25 '15 at 15:00
  • @DStanley only .xlsx files. – Big Pimpin Mar 25 '15 at 15:01
  • Why don't you just read it straight into an array rather than a datatable? Or at worst fill a `List<>` and convert that to an array. – D Stanley Mar 25 '15 at 15:02
  • @DStanley my beginning skills aren't sure how to read that into a List or an Array. I am unclear of the set-up. I know how to take the datatable to an array, but not go straight to an array. – Big Pimpin Mar 25 '15 at 15:03
  • 1
    You don't need a `DataTable`. See [this question](http://stackoverflow.com/questions/16221916/microsoft-office-interop-excel-or-epplus-for-read-a-huge-or-not-excel-file) on reading a column of data using EPPlus. – D Stanley Mar 25 '15 at 15:08

0 Answers0