Open And Fetch Data From A Listobject Of An Excel Sheet With Python
The Problem: Open a ListObject (excel table) of an Excel file from y python environment. The why: There are multiple solutions to open an excel file in python. Starting with pandas
Solution 1:
James is right:
https://openpyxl.readthedocs.io/en/stable/worksheet_tables.html
https://openpyxl.readthedocs.io/en/stable/api/openpyxl.worksheet.table.html
There is a class in openpyxl to read tables. Also by id:
class openpyxl.worksheet.table.Table(id=1,...
id=1 would mean the first table of the worksheet.
Remember always that ListObjects in Excel are called Tables. Thats weird (as oft with VBA). If you work with VBA you might forget that the ListObject=Table.
With xlwings is also possible. The API is a bit different:
import xlwings as xwwb= xw.Workbook.active()
xw.Range('TableName[ColumnName]').value
Or to get the column including header and Total row, you could do:
xw.Range('TableName[[#All], [ColumnName]]').value
Post a Comment for "Open And Fetch Data From A Listobject Of An Excel Sheet With Python"