Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Instantiate a Workbook object by excel file path
workbook = self.Workbook('Book1.xls')
# Access the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
# Delete a column from the worksheet at 2nd position
worksheet.getCells().deleteColumns(1,1,True)
# Save the modified Excel file in default (that is Excel 2003) format
workbook.save("Insert Column.xls")
# Instantiate a Workbook object by excel file path
workbook = self.Workbook("Book1.xls")
# Access the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
# Delete 10 rows from the worksheet starting from 3rd row
worksheet.getCells().deleteRows(2,10,True)
# Save the modified Excel file in default (that is Excel 2003) format
workbook.save("Insert Row.xls")
# Instantiate a Workbook object by excel file path
workbook = self.Workbook('Book1.xls')
# Access the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
# Insert a column into the worksheet at 2nd position
worksheet.getCells().insertColumns(1,1)
# Save the modified Excel file in default (that is Excel 2003) format
workbook.save("Insert Column.xls")
# Instantiate a Workbook object by excel file path
workbook = self.Workbook("Book1.xls")
# Access the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
# Insert a row into the worksheet at 3rd position
worksheet.getCells().insertRows(2,1)
# Save the modified Excel file in default (that is Excel 2003) format
workbook.save("Insert Row.xls")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment