Simple Help

Jul 24, 2011 at 2:14 AM

Hi... I just tried to create a simple worksheet in a windows app in C#, VS2010... I step through the debugger and nothing throws an error BUT the spreadsheet doesn't get written.   Without posting the code, is there something obvious that I may be missing?   I used the EPPlusSample.Sample1.cs as a guide.



Jul 24, 2011 at 2:16 AM

Maybe you forgot to call Save method ?

Jul 24, 2011 at 2:40 AM

I got that ... when I don't create a worksheet I do get an error saying there must be at least 1 worksheet so I think that the Save() is working.   I've stripped the code down to almost nothing:

Here is the calling code

          RenewalWorksheet o = new RenewalWorksheet();

And here is the class:

  public class RenewalWorksheet
    protected FileInfo xlsFile;

    public RenewalWorksheet() { }

    public void CreateFile()
      FileInfo xlsFile = new FileInfo(@"C:\temp\AAAA.xlsx");
      if (xlsFile.Exists)
        xlsFile.Delete();  // ensures we create a new workbook
        xlsFile = new FileInfo(@"C:\temp\AAAA.xlsx");
    protected void CreateSummaryPage(ExcelPackage e)
      ExcelWorksheet work = e.Workbook.Worksheets.Add("Summary");

      work.Cells[1,1].Value = "region";
      work.Cells[1,2].Value = "applicationstatus";
      work.Cells[1,3].Value = "Tot_Leagues";

    public void Generate()
        using (ExcelPackage package = new ExcelPackage(this.xlsFile))

      catch (Exception e)

Jul 24, 2011 at 2:55 AM

Never mind... stupid me... brain fart... had local instance of the file not going to the property... it's working now... thanks...