0

I'm using the sample code below to create a spreadsheet using EPPlus.dll, but FileInfo is not recognized.

EPPlus.dll has been added as a reference via the Package Manager Console and the other objects and references such as ExcelPackage and ExcelWorksheet are correctly recognized, but FileInfo has the swiggly redline underneath it stating that Type or Namespace cannot be found.

Any thoughts as to why?

  • .Net Framework 4
  • c#

    using OfficeOpenXml;
    using (ExcelPackage xlWorkBook = new ExcelPackage())
    {
        ExcelWorksheet sheet = xlWorkBook.Workbook.Worksheets.Add("MySheet");
    
        sheet.Cells["A1"].Value = "testing";
        xlWorkBook.SaveAs(new FileInfo(@"c:\myworkbook.xlsx"));
    }
    
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Ty S
  • 1
  • 2

1 Answers1

0

Finally figured it out. The directive "using System.IO;" is required.

Ty S
  • 1
  • 2