首页 > 其他 > 详细

读取excel合并单元格内容

时间:2018-12-19 00:53:27      阅读:170      评论:0      收藏:0      [点我收藏+]
 1  def get_excel_content(excel_path):
 2         contents = []
 3         if self.log_path.endswith(xls):
 4             workbook = xlrd.open_workbook(excel_path, formatting_info=True)
 5             sheet = workbook.sheet_by_index(0)
 6             start_row = 0
 7             for cell in sheet.merged_cells:
 8                 row, row_range, col, col_range = cell
 9                 if row != start_row:
10                     # print()
11                     start_row = row
12                     at_1st_col = True
13                 else:
14                     at_1st_col = False
15                 if at_1st_col or start_row == 0:
16                     content = [item for item in sheet.row_values(row) if (item and item != / or item == 0)]
17                     if content:
18                         # print(content, end="        ")
19                         contents.append(content)
20         return contents

 

读取excel合并单元格内容

原文:https://www.cnblogs.com/linyihai/p/10140958.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!