Using xlsxwriter, how do I insert a new row to an Excel worksheet? For instance, there is an existing data table at the cell range A1:G10 of the Excel worksheet, and I want to insert a row (A:A) to give it some space for the title of the report.
I looked through the documentation here http://xlsxwriter.readthedocs.io/worksheet.html, but couldn't find such method.
import xlsxwriter
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('Expenses01.xlsx')
worksheet = workbook.add_worksheet()
worksheet.insert_row(1) # This method doesn't exist
Unfortunately this is not something xlsxwriter
can do.
openpyxl
is a good alternative to xlsxwriter
, and if you are starting a new project do not use xlsxwriter
.
Currently openpyxl
can not insert rows, but here is an extension class for openpyxl
that can.
openpyxl
also allows reading of excel documents, which xlsxwriter
does not.