uhrb / excellibrary

Automatically exported from code.google.com/p/excellibrary
0 stars 0 forks source link

Delete Sheet trouble #135

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Execute the code below for an attached file "2.xls" and sheet "NullValue":
private void DeleteSheet(string excelfile, string sheet)
{
    bool found = false;
    Workbook book;

    book = Workbook.Load(excelfile);
    for (int i = 0; i < book.Worksheets.Count(); i++)
    {
        string iSheet = book.Worksheets[i].Name;
        if (iSheet == sheet)
        {
            book.Worksheets.RemoveAt(i);
            found = true;
            break;
        }
    }

    string newExcelfile = Path.Combine(Path.GetDirectoryName(excelfile), Path.GetFileNameWithoutExtension(excelfile) + "_new" + Path.GetExtension(excelfile));

    if (found) book.Save(newExcelfile);
    else throw new Exception(string.Format("Sheet \"{0}\" was't found", sheet));
}

2. Open created file "2_new.xls" using Microsoft Excel 2010.

What is the expected output? What do you see instead?
Expected: file opened successfully. There is no sheet with name "NullValue".
Actual: an error occurs while opening file (see screenshot.png)

2_my_new.xls - is a file, generated on my machine.

What version of the product are you using? On what operating system?
The latest version ExcelLibrary_20110730.zip    Jul 2011

Please provide any additional information below.

Original issue reported on code.google.com by jWales...@gmail.com on 12 Jul 2012 at 2:17

Attachments:

GoogleCodeExporter commented 9 years ago
Windows 7, 32-bit

Original comment by jWales...@gmail.com on 12 Jul 2012 at 2:18