To import data from an open Excel window into Python

Asked 2 years ago, Updated 2 years ago, 40 views

**

Get the data of the turned-on Excel window right away without saving the Excel file I want to know how to code. Help!

**

I'm a beginner who wants to automate the company's work with Python.

I learned how to use data by bringing Excel file to Pandas during Python beginner level study.

But in practice, eksselchang on the data to enter a value that comes out, just enter a company computer networks

.

I'm using the method. You can retrieve the data of the turned-on Excel window immediately without saving the Excel file

I want to know how to code. Help!

python excel

2022-09-22 18:26

1 Answers

I'm not sure.It's uncomfortable.

There is a module that can handle COM, so you can use it.I think Pandas would be better.

Install pywin32 (pip install pywin32) and handle ole objects.

Run Excel, open one file, and put it in edit state.

Try running the code below.

import win32com.client

excel = win32com.client.Dispatch("Excel.Application")
sheet = excel.activesheet
print(sheet.Cells(2, 1).Value) # 2nd row 1st row value output

Please refer to the help below for API information for each object.

https://docs.microsoft.com/en-us/office/vba/api/overview/excel/object-model


2022-09-22 18:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.