New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Application.calculation #158

Closed
willu47 opened this Issue Feb 27, 2015 · 6 comments

Comments

Projects
None yet
2 participants
@willu47

willu47 commented Feb 27, 2015

I am running a series of simulations in Excel, and need to write, and then read a bunch of cells within a Python loop.

Currently, when writing data to Excel using Range('Sheetname', (row, col)).value = new_value, the worksheet recalculates each time.

Is there anyway to turn off sheet calculation until all the writes have been made, then calculate once?

@fzumstein fzumstein added this to the v0.3.3 milestone Feb 27, 2015

@fzumstein

This comment has been minimized.

Member

fzumstein commented Feb 27, 2015

I am just currently implementing the Application class, so that would fit in there... Chances are that it ll make it into the next release :)

@willu47

This comment has been minimized.

willu47 commented Feb 27, 2015

Great!

@fzumstein

This comment has been minimized.

Member

fzumstein commented Feb 27, 2015

Other than that you can do the following for a quick workaround until it's implemented:

wb = Workbook()
wb.xl_app.ScreenUpdating = False
@fzumstein

This comment has been minimized.

Member

fzumstein commented Feb 27, 2015

sorry you wanted Calculation not ScreenUpdating

@fzumstein

This comment has been minimized.

Member

fzumstein commented Feb 27, 2015

so you could do:

In[5]: from xlwings import Calculation
In[6]: wb.xl_app.Calculation =Calculation.xlCalculationManual
In[7]: Range('A1').value = 1
In[8]: wb.xl_app.Calculation = Calculation.xlCalculationAutomatic
@willu47

This comment has been minimized.

willu47 commented Feb 27, 2015

That's perfect. A huge speed up! Thanks so much ;)

@fzumstein fzumstein changed the title from Writing to Excel worksheet involves sheet calculation for each write to Add Application.Calculation Feb 27, 2015

@fzumstein fzumstein changed the title from Add Application.Calculation to Add Application.calculation Feb 27, 2015

@fzumstein fzumstein closed this in 3a6f576 Feb 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment