chronossc/openpyxl

Delete rows corrupts the file

Closed this issue · 0 comments

I have an extract from SAP file in excel and I'm simply trying to delete few initial rows, here's the script-

import openpyxl as xl
wb = xl.load_workbook("/path/to/file")
ws = wb.worksheets[0]
ws.delete_rows(0, 3)
wb.save("/path/to/file")

Here's the error thrown by excel-

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error042400_03.xml</logFileName><summary>Errors were detected in file 'C:\Users\sjariwala\Documents\ABB\data\preprocessedviews\INABB PG view Jun18.xlsx'</summary><removedParts><removedPart>Replaced Part: /xl/worksheets/sheet1.xml part with XML error.  Load error. Line 1, column 0.</removedPart></removedParts></recoveryLog>