class SapGuiTableControl: """ 读取GuiTableControl对象的数据。 """ @staticmethod def get_data(session, _id, columns=None): """ 获取指定列的数据,索引从0开始。 :param session: SAP的GuiSession对象。 :param _id: SAP组件ID。 :param columns: 需要获取数据的列索引。 """ result = [] tbl = session.findById(_id) # 如果没有指定要读取的列,则读取全部列 columns = columns or [i for i in range(tbl.Columns.Count)] row_number = 0 page = 0 old_position = -1 new_position = 0 # 滚动到下页的位置没有变更,则表示到达最后一页 while old_position != new_position: rows_per_page = tbl.Children.Count // tbl.Columns.Count page += 1 # 读取一页的数据 for row in range(rows_per_page): row_data = [tbl.GetCell(row, column_number).Text for column_number in columns] result.append(row_data) # print("Page:", page, "PageSize:", str(row + 1) + '/' + str(rows_per_page), row_data) row_number += rows_per_page # 滚动到下页的位置 next_page_position = tbl.VerticalScrollbar.Position + tbl.VisibleRowCount old_position = tbl.verticalScrollbar.position tbl.verticalScrollbar.position = next_page_position # 获取翻页后的表格控件对象 tbl = session.findById(_id) new_position = tbl.verticalScrollbar.position return result
https://blog.csdn.net/chenguangqi/article/details/125787415?spm=1001.2014.3001.5502
标签:读取数据,row,per,tbl,position,SAP,page,columns,TableControl From: https://www.cnblogs.com/pythonClub/p/17655264.html