openpyxl库的使用,这个处理xlsx还是挺有用的

ref:传送门

 from openpyxl import Workbook
from openpyxl import load_workbook
from openpyxl.cell import get_column_letter #---------------读取表内容
wb=load_workbook(filename=r'1.xlsx'); #打开一个xlsx文件
sheetnames = wb.get_sheet_names() # get a list of all the sheet names in the workbook by calling the get_sheet_names() method
ws = wb.get_sheet_by_name(sheetnames[0]) #获取第一个表
for i in range(1,3): #获取表内容 或者ws['B2'].value
for j in range(1,4):
print ws.cell(row=i,column=j).value,
print
print ws.max_column,ws.max_row; #获取行,列数
print get_column_letter(6);
for i in ws['A1':'C2']: #获取每一行
#print i
for j in i:
print j.coordinate,j.value #-------------创建表写入内容
a=Workbook()
a.create_sheet(index=0,title='') #表名
sheet=a.get_sheet_by_name('');
for i in range(1,5):
for j in range(1,2):
sheet.cell(row=i,column=j).value=''
'''
for i in sheet['A1':'C5']:
for j in i:
j.value='6';
'''
a.save('6.xlsx');

openpyxl的更多相关文章

  1. Python excel 库:Openpyxl xlrd 对比 介绍

    打算用python做一个写mtk camera driver的自动化工具. 模板选用标准库里面string -> Template 即可 但要重定义替换字符,稍后说明 配置文件纠结几天:cfg, ...

  2. python 脚本中使用了第三方openpyxl 打包程序运行提示ImportError:cannot import name __version__

    最近写了一个脚本,脚本中使用了第三方openpyxl(openpyxl是使用 pip install openpyxl 下载的),先是使用py2exe打包程序,打包过程中提示很多文件没有包含,在没有仔 ...

  3. python openpyxl 操作 excel

    初识与安装 Openpyxl is a Python library for reading and writing Excel 2010 xlsx/xlsm/xltx/xltm files. 安装 ...

  4. win7下安装openpyxl

    想使用python来操作Excel,看资料据说openpyxl非常好用,于是到https://pypi.python.org/pypi/openpyxl下载了安装包.下面就来说说安装步骤,也算是对自己 ...

  5. python 模块openpyxl读excel文件

    使用openpyxl模块来读取excel.要注意openpyxl读不再支持旧的xls格式. 先看一下操作前的excel是什么样子吧.对了,现在只支持xlsx格式的excel读取 我现在想在第三行插入3 ...

  6. python 使用openpyxl来写数据到excel表格

    使用openpyxl写execl确实很方便.我先介绍用到的相关模块与函数 Workbook:工作簿模块,在内存创建一个工作簿. ExcelWriter:使用它向exel中写数据. get_column ...

  7. Python使用openpyxl读写excel文件

    Python使用openpyxl读写excel文件 这是一个第三方库,可以处理xlsx格式的Excel文件.pip install openpyxl安装.如果使用Aanconda,应该自带了. 读取E ...

  8. python中openpyxl的用法【安装,以及一些基本的操作】

    概述 Openpyxl是python中简单易用的操作excel电子表格的一个模块.接下来呢,跟博主一起学习一下吧  ----_<_>_---- 首先先清楚一些excel的基本概念: 在op ...

  9. python用openpyxl操作excel

    python操作excel方法 1)自身有Win32 COM操作office但讲不清楚,可能不支持夸平台,linux是否能用不清楚,其他有专业处理模块,如下 2)xlrd:(读excel)表,xlrd ...

随机推荐

  1. Android利用百度地图定位

    百度地图照着百度的教程做的总是出现报错 请帮我看看错误在那 2013-12-13 15:16168海军 | 分类:百度地图 | 浏览1252次 java.lang.RuntimeException: ...

  2. angular2 学习笔记 ( ngModule 模块 )

    2016-08-25, 当前版本是 RC 5. 参考 : https://angular.cn/docs/ts/latest/guide/ngmodule.html 提醒 : 这系列笔记的 " ...

  3. 游览器保存密码和自动填充密码的困惑 (browser save password and auto fill password )

    原文 refer : http://www.cnblogs.com/happyfreelife/p/4240100.html 当一个带有username and password 的表单被提交, 游览 ...

  4. Collections.shuffle源码阅读

    java.util.Collections /** * Randomly permutes the specified list using a default source of * randomn ...

  5. linux中fork()函数

    man fork: FORK() Linux Programmer's Manual FORK(2) NAME fork - create a child process SYNOPSIS #incl ...

  6. 九度oj 1482:玛雅人的密码

    题意:输入一个长度为n(2<=n<=13)的字符串(所有字符为'0','1'或'2'),通过交换相邻的两个字符,至少要交换多少次才能处出现字串"2012",输出这个值, ...

  7. POJ1017 packets

    Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 48911   Accepted: 16570 Descrip ...

  8. 使用python进行接口测试(二)

    之前使用过urllib和urllib2做接口测试,在做的途中,感觉使用urllib2直接进行的get,post 请求并没有那么好用.作为测试人员,所需要的测试工具应当以方便为第一要务,测试的耗时只要是 ...

  9. RequireJS 2.0 新特性

    就在前天晚上RequireJS发布了一个大版本,直接从version1.0.8升级到了2.0.随后的几小时James Burke又迅速的将版本调整为2.0.1,当然其配套的打包压缩工具r.js也同时升 ...

  10. 解决html5新标签【placeholder】低版本浏览器下不兼容问题

    placeholder属性是HTML5 中为input添加的.在input上提供一个占位符,文字形式展示输入字段预期值的提示信息(hint),该字段会在输入为空时显示. 实例:1 <input ...