pythonopenpyxl怎么将数组写⼊excel_Python-使⽤openpyxl
模。。。
Openpyxl是⽤于读取和写⼊Excel(扩展名为xlsx / xlsm / xltx / xltm)⽂件的Python库。openpyxl模块允许Python程序读取和修改
Excel⽂件。
例如,⽤户可能必须遍历数千⾏并挑选⼀些信息,才能根据某些条件进⾏较⼩的更改。使⽤Openpyxl模块,可以⾮常有效且轻松地完成这
些任务。
⽰例# import openpyxl module
import openpyxl
#Call a Workbook() func of openpyxl to create a new blank Workbook object
wb = openpyxl.Workbook()
# Get workbook active sheet from the active attribute
sheet = wb.active
# Cell objects also have row, column and coordinate attributes that provide
# location information for the cell.
# The first row or column integer is 1, not 0. Cell object is created by
python怎么读入excel# using sheet object's cell() method.
c1 = ll(row = 1, column = 1)
# writing values to cells
c1.value = "Vishesh"
c2 = ll(row= 1 , column = 2)
c2.value = "Ved"
#Once have a Worksheet object,one can access a cell object by its name also
# A2 means column = 1 & row = 2.
c3 = sheet['A2']
c3.value = "Python"
# B2 means column = 2 & row = 2.
c4 = sheet['B2']
c4.value = "Programming"
#Anytime you modify the Workbook object or its sheets and cells, the #spreadsheet file will not be saved until you call the #sav
wb.save("C:\\Users\\Vishesh\\Desktop\\demo.xlsx")
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论