Update an Excel sheet in real time using Python

0 votes

Is it possible to update a spreadsheet open in Excel in real-time? I have the following Python code that tries to update cell B1 with the text "ID" in an Excel worksheet called Example.xlsx:

import openpyxl

wb = openpyxl.load_workbook('Example.xlsx')
sheet = wb['Sheet']
sheet['B1'] = 'ID'

wb.save('Example.xlsx')

On running the script I get this error:

PermissionError: [Errno 13] Permission denied: 'Example.xlsx'. I'm aware that this is the case because Excel is currently opening the file, but I was wondering if there was another method or module I could use to update a sheet while it is open.

Nov 13, 2022 in Others by Kithuzzz
• 38,000 points
3,206 views

1 answer to this question.

0 votes

Using xlwings, I have really discovered how to do this, and it is very straightforward. The code that follows accesses Example.xlsx, an existing Excel file, and updates it in real-time. In this case, it immediately enters the number 45 in cell B2 when you run the script.

import xlwings as xw

wb = xw.Book('Example.xlsx')
sht1 = wb.sheets['Sheet']
sht1.range('B2').value = 45
answered Nov 13, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How to save a new sheet in an existing excel file, using Pandas?

import pandas as pd import numpy as np path ...READ MORE

answered Dec 10, 2022 in Others by narikkadan
• 63,600 points
7,594 views
0 votes
1 answer

Is it possible to get data from a webpage in real-time to an excel file?

The conventional method of obtaining data from ...READ MORE

answered Jan 17, 2023 in Others by narikkadan
• 63,600 points
548 views
0 votes
1 answer

Calculate Birthdate from an age using y,m,d in Excel

Hello, yes u can find your birthdate using ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
4,132 views
0 votes
1 answer

Calculate Birthdate from an age using y,m,d in Excel

Hi To Calculate the date, we can ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
2,013 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,600 points
1,397 views
0 votes
1 answer

Format an Excel Sheet in Python

The below code will help you refer ...READ MORE

answered Nov 6, 2022 in Others by narikkadan
• 63,600 points
1,374 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP