private static void DeleteFirstWorksheet(SpreadsheetLight.SLDocument document) { Debug.Assert(document != null); // If we have just one worksheet then test was empty (!) or something went wrong, // just do nothing and let caller manage an erroneous situation (if any) var worksheets = document.GetWorksheetNames(); if (worksheets.Count > 1) { document.DeleteWorksheet(worksheets[0]); } }