首页 > 编程语言 > 详细

Python openpyxl Read

时间:2016-01-26 12:11:56      阅读:153      评论:0      收藏:0      [点我收藏+]
技术分享
#! /usr/bin/env python
# coding=utf-8


from openpyxl import Workbook, load_workbook


wb = load_workbook(filename=u周工作计划_联通电信支撑组.xlsx)
ws = wb.active

# wb = load_workbook(filename=u‘test1.xlsx‘)



# for sname in wb.get_sheet_names():
# # for sname in wb.sheetnames:
# #     ws = wb.get_sheet_by_name(sname)
# #     print ws.title
#     ws = wb[sname]
#     print ws.title
     
#      
# for sheet in wb:
#     print sheet.title


# print wb.sheetnames
# for sheet in wb:
#     print(sheet.title)





# print ws.title

# # 行列数
# print ws.max_row
# print ws. max_column

# print ws.min_row
# print ws.min_column

# for row in ws.rows:
#     
#     for cell in row:
#         print cell.value,
#     print

# # cell = ws[‘E4‘]
# # cell = ws.cell(‘E4‘)
# cell = ws.cell(row=4, column=5)
# print cell
# print cell.value
# 
# cell_range = ws[‘D3:E16‘]
# 
# print cell_range
# for row in cell_range:
#     for cell in row:
#         print cell.value,
#     print


# for row in ws.iter_rows(‘D3:E16‘):
#     for cell in row:
#         print cell.value,
#     print



‘‘‘
表头占两行:

项目 类型 优先级 运营点 需求标题(对应需求文档) 完成时间 评审计划 UR 状态 负责?? None None None None None 完成时间 None None None None None None None None 周工作量投入(人.h) None 成本估算(人.h) None
None None None None None None None None None 需求 外部资源 设计 提示音 开发 测试 需求 外部资源 设计 提示音 开发 内测 部署 外测 验收 开发 测试 开发 测试

‘‘‘
#  min_col, min_row, max_col, max_row



for ws in wb:
    
    min_col = 4  # 前面三列分别是项目 、类型、 优先级,从第四列  运营点 开始选择
    min_row = 3  # 前面两行是表头,从第三列开始选择
    max_col = 15  # 勾选到 到 负责人-测试 这列 
    max_row = ws.max_row - 1  # 排查最后一行(日常事务处理)
    
    print * * 20, ws.title, * * 20
    for row in ws.get_squared_range(min_col, min_row, max_col, max_row): 
        for cell in row:
            print cell.value,
        print


# print tuple(ws.iter_rows(‘D3:E16‘))

# print ws.rows
# print ws.columns
View Code

 

Python openpyxl Read

原文:http://www.cnblogs.com/ryhan/p/5159745.html

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