zoukankan      html  css  js  c++  java
  • Python openpyxl Read

    #! /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
  • 相关阅读:
    void及void指针含义的深刻解析
    jbpm入门样例
    给字符数组赋值的方法
    linux tar.gz zip 解压缩 压缩命令
    android 文件上传
    职员有薪水了
    sublime配置全攻略
    [置顶] WPF数据修改demo
    Java实现快速排序
    Java实现快速排序
  • 原文地址:https://www.cnblogs.com/ryhan/p/5159745.html
Copyright © 2011-2022 走看看