Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active May 4, 2022 13:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/db8bf666a8cfa3faf857e1ad608149f3 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/db8bf666a8cfa3faf857e1ad608149f3 to your computer and use it in GitHub Desktop.
# 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