I'm working on a project which I am going to write values to a exceldocument. I can write values to excel but I want to write the values to excel with the document open. If i have the doc open when trying to write to it i get an error message.
Here is my code I'm currently using.
#Write to excel
from openpyxl import Workbook
import datetime
wb = Workbook()
ws = wb.active
ws['C3'] = 1337
ws['A1'] = datetime.datetime.now()
ws['B5'] = CIRCLES
ws['B4'] = "Red puck"
wb.save("sample.xlsx")
And the error message when i have the doc. opened when trying to write to it.
Traceback (most recent call last):
File "C:\Users\RU21\Desktop\Röda puckar\Förbindelse med RR.py", line 302, in <module>
wb.save("sample.xlsx")
File "C:\Python27\lib\site-packages\openpyxl\workbook\workbook.py", line 280, in save
save_workbook(self, filename)
File "C:\Python27\lib\site-packages\openpyxl\writer\excel.py", line 211, in save_workbook
writer.save(filename)
File "C:\Python27\lib\site-packages\openpyxl\writer\excel.py", line 193, in save
archive = ZipFile(filename, 'w', ZIP_DEFLATED)
File "C:\Python27\lib\zipfile.py", line 756, in __init__
self.fp = open(file, modeDict[mode])
IOError: [Errno 13] Permission denied: 'sample.xlsx'