所以我在python中编写一个简单的测试代码,但我似乎无法加载我的工作簿来读写。我试图打开的工作簿有很多数据,并链接到Access数据库。我也在使用Python 2.7。
以下是代码:
from openpyxl import Workbook
from openpyxl import load_workbook
print("here1")
wb = load_workbook("Z:\\PythonFiles\\testexcel2.xlsx")
print("here2")
ws1 = wb.get_sheet_by_name("Output Model")
import datetime
print("here3")
ws1.cell(row=3, column=9).value="Somevalue2"
wb.save("Z:\\PythonFiles\\testexcel2.xlsx")
现在出现错误:
here1
Traceback (most recent call last):
File "Z:\PythonFiles\Test.py", line 4, in <module>
wb = load_workbook("Z:\\PythonFiles\\testexcel2.xlsx")
File "C:\Python27\openpyxl\reader\excel.py", line 233, in load_workbook
parser.parse()
File "C:\Python27\openpyxl\reader\worksheet.py", line 104, in parse
dispatcher[tag_name](element)
File "C:\Python27\openpyxl\reader\worksheet.py", line 235, in parse_row_dimensions
self.parse_cell(cell)
File "C:\Python27\openpyxl\reader\worksheet.py", line 191, in parse_cell
value = _cast_number(value)
File "C:\Python27\openpyxl\reader\worksheet.py", line 55, in _cast_number
return int(value)
ValueError: invalid literal for int() with base 10: '1E-3'
答案 0 :(得分:0)