1.python 怎么安装 openpyxl
例子
from openpyxl import Workbook
wb = Workbook()
# 激活 worksheet
ws = wb.active
# 数据可以直接分配到单元格中
ws['A1'] = 42
# 可以附加行,从第一列开始附加
ws.append([1, 2, 3])
# Python 类型会被自动转换
import datetime
ws['A3'] = datetime.datetime.now().strftime("%Y-%m-%d")
# 保存文件
wb.save("sample.xlsx")
2.openpyxl需不需要安装excel
from openpyxl.reader.excel import load_workbook
wb=load_workbook(r'd:\foo1.xlsx')
ws=wb.get_sheet_by_name('Bar')
ws.cell('A1').value= 'new_value'
# save the workbook to a new file to finish the editing
# but the style settings has been removed (such like font, color) in the new file
wb.save(r'd:\foo2.xlsx')
3.openpyxl需不需要安装excel
from openpyxl.reader.excel import load_workbook
wb=load_workbook(r'd:\foo1.xlsx')
ws=wb.get_sheet_by_name('Bar')
ws.cell('A1').value= 'new_value'
# save the workbook to a new file to finish the editing
# but the style settings has been removed (such like font, color) in the new file
wb.save(r'd:\foo2.xlsx')
4.python3.4安装openpyxl报错,麻烦高手帮忙看看什么原因
你遇到的问题一看就是少装了包。在windows下安装pandas,只安装pandas一个包显然是不够的,它并没有把用到的相关包都打进去,这点是很麻烦的,只有等错误信息出来后才知道少了哪些包。
我总结了一下,一共需要安装如下包:
pyparsing-2.0.2.win32-py2.7.exe
matplotllib-1.3.1.win32-py2.7.exe
openpyxl-openpyxl-5d2c0c8704d2.tar.gz
setuptools-3.8.1.win32-py2.7.exe
numpy-MKL-1.8.1.win32-py2.7.exe
six-1.7.3.win32-py2.7.exe
python-dateutil-2.2.win32-py2.7.exe
转载请注明出处windows之家 » win10下安装openpyxl