Python Forum
Access xlsm file that has been open
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access xlsm file that has been open
#1
I use openpyxl in python 3.6.1 to read/write xlsm file of Excel 2010.
Is there a way to access the file, that has been opened manually, without open it again in code? Thanks.

my code here
Reply
#2
I believe you can open an excel file more than once, so long as it's only opened for writing once,
and for good reason. There is no sharing, or locking mechanism, so that makes perfectly food
sense.
Reply
#3
If the question is "can I read inside Excel's memory to figure out which file it s currently working with (assuming there is only one...) and do things to it with Python" the answer is no, and anyway if you change anything in the file, Excel won't see it and will overwrite them on exit.

So, why are you trying to do this?
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#4
Thank you for your replies. I need to retrieve some data records and display them on something like spreadsheet, and timely update them while displaying. If Excel file no good, is there a way to use python GUI or something to do it? If yes, is there some sample codes for it? thanks again.

I have been using Microsoft Powershell / VBA to do it but feel slow. I was told python is faster than java or C++.
Reply
#5
If you are planning on having a graphical display, the wxpython package has a grid widget
see: https://web.cs.wpi.edu/~mebalazs/wxClips/wxc144.htm.

if you want to display excel in python, you can use pandas
see: https://stackoverflow.com/questions/1063...-or-matrix
Reply
#6
Thank you for your samples that are very informative.
I found below but not sure how to get gridlines displayed. Is there a way to do that? Thanks

import tkinter
grid = tkinter.Tk()
for r in range(15):
for c in range(10):
tkinter.Label(grid, text='R%s/C%s'%(r,c)).grid(row=r,column=c)
grid.mainloop()
Reply
#7
The tkinter grid has nothing to do with displaying a grid. It is a geometry,
and has to do with laying out the widgets in a grid (row, column) format.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CSV file dont open with code ayaz786amd 2 2,573 Nov-21-2018, 09:13 AM
Last Post: ayaz786amd
  [split] Locate and open csv file agocomp 3 3,353 Dec-02-2017, 07:02 AM
Last Post: buran
  Open excel file using Python cioer23 8 19,389 Jul-26-2017, 10:57 AM
Last Post: Larz60+
  access a very large file? As an array or as a dataframe? Angelika 5 4,861 May-18-2017, 08:15 AM
Last Post: Angelika

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020