Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 9, 2021 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/149106ad8c13c30e1d7c386917442147 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/149106ad8c13c30e1d7c386917442147 to your computer and use it in GitHub Desktop.
# Load Excel workbook
wb = Workbook("workbook.xlsx")
# Get worksheets collection
collection = wb.getWorksheets()
collectionCount = collection.getCount()
# Loop through all the worksheets
for worksheetIndex in range(collectionCount):
# Get worksheet using its index
worksheet = collection.get(worksheetIndex)
# Print worksheet name
print("Worksheet: " + str(worksheet.getName()))
# Get number of rows and columns
rows = worksheet.getCells().getMaxDataRow()
cols = worksheet.getCells().getMaxDataColumn()
# Loop through rows
for i in range(rows):
# Loop through each column in selected row
for j in range(cols):
# Print cell value
print(worksheet.getCells().get(i, j).getValue(), end =" | ")
# Print line break
print("\n")
# Load Excel workbook
wb = Workbook("workbook.xlsx")
# Get worksheets collection
worksheet = wb.getWorksheets().get(0)
# Print worksheet name
print("Worksheet: " + str(worksheet.getName()))
# Get number of rows and columns
rows = worksheet.getCells().getMaxDataRow()
cols = worksheet.getCells().getMaxDataColumn()
# Loop through rows
for i in range(rows):
# Loop through each column in selected row
for j in range(cols):
# print cell value
print(worksheet.getCells().get(i, j).getValue(), end =" | ")
# Print line break
print("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment