Reputation: 31
I was wondering if anyone knew how to take the title of a specific Excel sheet and find the index of it using asposecells
? Here is my code to start:
ws=wb.getWorksheets().get(1)
What I'd like to do is replace what's inside the get
function with whatever index the worksheet with the specific title is at. Let's say the name of the worksheet is "Example"
for instance. How could I take a workbook with that worksheet and find the index of that specific worksheet so I could extract it with this line of code?
Upvotes: 1
Views: 136
Reputation: 1931
Here is a sample code using Aspose.Cells for Python via Java to demonstrate how to retrieve a worksheet in the workbook by its name and then find its relevant index for your reference.
e.g.,
Sample code:
...
workbook = Workbook("Book1.xlsx")
# Accessing a worksheet using its sheet name
worksheet = workbook.getWorksheets().get("Example")
# Get the index of the worksheet - it is 0 based
# E.g., first sheet index would be 0, second sheet's index is 1 and so on...
sheetIndex = worksheet.getIndex()
# Print the worksheet index
print(sheetIndex)
Hope this helps a bit. Also, you may post your queries in the dedicated forum.
PS. I am working as Support developer/ Evangelist at Aspose.
Upvotes: 1