Update an Excel sheet in real time using Python

前端 未结 4 753
孤街浪徒
孤街浪徒 2021-02-15 08:23

Is there a way to update a spreadsheet in real time while it is open in Excel? I have a workbook called Example.xlsx which is open in Excel and I have the following python code

4条回答
  •  耶瑟儿~
    2021-02-15 09:01

    I have actually figured this out and its quite simple using xlwings. The following code opens an existing Excel file called Example.xlsx and updates it in real time, in this case puts in the value 45 in cell B2 instantly soon as you run the script.

    import xlwings as xw
    
    wb = xw.Book('Example.xlsx')
    sht1 = wb.sheets['Sheet']
    sht1.range('B2').value = 45
    

提交回复
热议问题