Deleting Ranges gives error

Jan 14, 2013 at 1:04 PM
Edited Jan 14, 2013 at 1:10 PM

Hello everybody,

well as the subject says i'm trying to delete a range in a sheet but i get the error

"<filename> contains unreadable content. Recover content from worksheet? Press yes if the worksheet is trustworthy"

(not a literal translation i guess, i got the localized error ;D)

I'm using the 3.5 .Net framework dll.

Here's some code; i would attach an ad hoc solution, but i guess i must open a bug in the issue tracker section, and i might be doing something wrong, so, maybe later =)

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClosedXML;
using System.IO;
using ClosedXML.Excel;
namespace ClosedXMLTest
{
    class Program
    {
        private static string filesourcepath = "..\\..\\File\\input.xlsx";
        private static string outputfilename = "..\\..\\File\\outpt.xlsx";
        static void Main(string[] args)
        {
            File.Copy(filesourcepath, outputfilename, true);
            XLWorkbook workbook = new XLWorkbook(outputfilename);

            workbook.Worksheet(1).Range("Sheet1DeleteMe").Delete(XLShiftDeletedCells.ShiftCellsUp);
            workbook.Worksheet(2).Range("Sheet2DeleteMe").Delete(XLShiftDeletedCells.ShiftCellsUp);

            workbook.SaveAs(outputfilename);
        }
    }
}

 

I know there's 2 sheets (Sheet1, Sheet2) and 2 named ranges (Sheet1DeleteMe,Sheet2DeleteMe) and i'm trying to delete them. 

Am I doing anything wrong?