码迷,mamicode.com
首页 > 其他好文 > 详细

读取excel合并单元格内容

时间:2018-12-19 01:10:40      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:单元格   merge   excel   pat   get   values   val   ret   false   

 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合并单元格内容

标签:单元格   merge   excel   pat   get   values   val   ret   false   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!