from openpyxl import load_workbook
class RwExcelFile: def read_Excel(self,file_path):
'''
读取excel中所有数据并以列表形式返回
:param file_path:
:return:
'''
excel_File = load_workbook(file_path)
sheet_names = excel_File.sheetnames
list_column = []
list_row = []
list_sheet = []
for i in sheet_names:
excel_File_sheet=excel_File[i]
for j in range(1,excel_File_sheet.max_row+1):
for k in range(1,excel_File_sheet.max_column+1):
list_column.append(excel_File_sheet.cell(j,k).value)
list_row.append(list_column)
list_column = []
list_sheet.append(list_row)
list_row = []
excel_File.close()
return list_sheet def write_Excel(self,file_path,sheetname,row,cloumn,T_value):
'''
向excel指定位置写入值
:param file_path: 文件地址
:param sheetname: sheet名
:param row: 行
:param cloumn:列
:param T_value: 值
:return: 无返回
'''
excel_File = load_workbook(file_path)
excel_File[sheetname].cell(row,cloumn,T_value)
excel_File.save(file_path)
excel_File.close()

python3 excel文件的读与写的更多相关文章

  1. python3中文件的读与写

    Python open() 函数用于打开一个文件,并返回文件对象,在对文件进行处理过程都需要使用到这个函数,如果该文件无法被打开,会抛出错误 完整语法:open(file, mode='r', buf ...

  2. POI完成Excel文件的读和写

    简介 Apache POI 是用Java编写的免费开源的跨平台的 Java API,Apache POI提供API给Java程式对Microsoft Office(Excel.WORD.PowerPo ...

  3. java 安卓开发之文件的读与写

    java文件的读与写,代码: String file="user.txt"; private void writeFileData(String str1, String str2 ...

  4. Json文件转换为Excel文件!涉及读文件,时间戳转化,写文档

    一. 思路 今天接到个小任务,让把json文件转换成excel文件,按照列展开. 思路:既然json已经都已经是现成的,那直接将json文件做读操作,在通过不同的key,找到对应的信息,在存到单元格中 ...

  5. python文件处理-读、写

    Python中文件处理的操作包括读.写.修改,今天我们一起来先学习下读和写操作. 一.文件的读操作 例一: #文件读操作 f = open(file="first_blog.txt" ...

  6. java后端导入excel模板和导入excel文件去读数据

    模板转载地址:https://www.cnblogs.com/zhangyangtao/p/9802948.html 直接上代码(我是基于ssm写的demo,导入文件目前只能读取.xls后缀的exce ...

  7. day5_函数_文件读写_用一个函数来满足文件的读或者写_应用默认参数

    import json def op_file_tojson(filename,dic=None): #默认值参数,根据是否传dic字典来判断读还是写 if dic: #如果dic传了值,不是空的,则 ...

  8. python中文件的读和写操作

    一.打开文件 data = open("yesterday",encoding="utf-8").read() # python默认的打字符编码是unicode ...

  9. python-ini文件使用(读和写)

    注意事项: 1.读文件: read(filename):读取ini文件中的内容 sections():得到所有section,返回列表形式 options(section):得到给定section的所 ...

随机推荐

  1. 20190211 模拟训练 A. 大猫咪

    好题 2.11考试

  2. usb驱动程序小结(六)

    title: usb驱动程序小结 tags: linux date: 2018/12/20/ 17:59:51 toc: true --- usb驱动程序小结 linux中为usb驱动也提供了一套总线 ...

  3. JAVA传递带有空格的参数

    String s="b2 + b1"; Process child = Runtime.getRuntime().exec("C:\\eclipse-workspace\ ...

  4. golang slice分割和append copy还是引用

    转载自:http://studygolang.com/articles/724 1. slice1:= slice[0:2] 引用,非复制,所以任何对slice1或slice的修改都会影响对方 dat ...

  5. C# Textbox 自动换行

    方法1 使用textbox的AppendText方法 方法2 textBox.ScrollToCaret(); this.textBox.Focus();//获取焦点 this.textBox.Sel ...

  6. UDP单播,广播,多播

  7. Leetcode#521. Longest Uncommon Subsequence I(最长特殊序列 Ⅰ)

    题目描述 给定两个字符串,你需要从这两个字符串中找出最长的特殊序列.最长特殊序列定义如下:该序列为某字符串独有的最长子序列(即不能是其他字符串的子序列). 子序列可以通过删去字符串中的某些字符实现,但 ...

  8. Angular7

    1.绑定html 在ts里面自定义一个html变量 html = '<a> 这是html变量 </a> '; 在html打印出来 直接打印:{{html}} <br /& ...

  9. Spring系列(二) Bean装配

    创建应用对象之间协作关系的行为称为装配(wiring), 这也是DI的本质. Spring中装配Bean的方式 Spring提供了三种装配Bean的方式. 隐式的Bean发现机制和自动装配 Java ...

  10. Ch02 课堂作业

    测试一:运行结果: 测试二:运行结果: 测试三:运行结果: