How can I delete a row from an excel using Open Office XML SDK

Sep 9, 2015 at 1:32 PM
I have written the below code to delete a row from an excel spreadsheet using OOXML . I can able to remove the row data , however the row still existing as a blank row. Please help me to completely remove the row from the excel file.

public static void DeleteRowFromExcel(string docName, string sheetName, uint rowIndex)
        // Open the document for editing.
        using (SpreadsheetDocument document = SpreadsheetDocument.Open(docName, true))
            IEnumerable<Sheet> sheets = document.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>().Where(s => s.Name == sheetName);
            if (sheets.Count() == 0)
                // The specified worksheet does not exist.
            string relationshipId = sheets.First().Id.Value;
            WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(relationshipId);
            Row row=GetRow(worksheetPart,rowIndex);