Formulas in named ranges causing corruption on saving file

Jan 4, 2013 at 5:52 AM
Edited Jan 4, 2013 at 5:54 AM

Are formulas in named ranges supported?  I'm having trouble with a spreadsheet which has some pre-defined named ranges in it.  When I save the file, the file is corrupted and can't be opened by excel  The range is defined as,

=OFFSET(Sheet1!$A1,0,0,COUNT(Sheet1!$A:$A)-1,1)

The file with this named range is called test_simple.xlsm

When I run the following code, the resulting file test_simple1.xlsm can't be opend by Excel (complains of corruption).  Any help would be appreciated.

 

var tmp = @"c:\temp\test_simple1.xlsm";
            File.Copy(@"c:\temp\test_simple.xlsm", tmp, true);

            using (ExcelPackage oo = new ExcelPackage(new FileInfo(tmp)))
            {
                oo.Workbook.Worksheets.Add("something");
                oo.Save();
            }