David BA
David BA

Reputation: 11

can xlwings run excel in the background?

I run a Python XLWings code where multiple Excel files are called sequentially. Although the code closes each Excel after dealing with it (and no more than 1 excel is open at any given moment), the process becomes increasingly slow. Memory tests show that residual processes remain after closing excel files.

Is there a smoother way to do this? Can maybe XLWings call these Excel files in background mode, without spending time and memory on loading the interface?

Thank you for your help.

Upvotes: 1

Views: 7189

Answers (1)

Xukrao
Xukrao

Reputation: 8644

Yes, xlwings does also allow you to keep the Excel application invisibly in the background. For this you must use an xlwings.App object with input parameter visible=False.

Simple example:

import xlwings as xw

app = xw.App(visible=False)
book = app.books[0]
sheet = book.sheets[0]

sheet.range('A1').value = 73913

book.save('book.xlsx')
app.kill()

Upvotes: 10

Related Questions