Karthic Raghupathi
Karthic Raghupathi

Reputation: 2061

How to set the zoom level for a workbook in OpenPyXL?

I searched around for quite a bit but I'm unable to figure out how to set the default zoom level of a document created using OpenPyXL. Can it be done? If yes, how?

I'm using OpenPyXL 2.0.5.

Upvotes: 9

Views: 8082

Answers (2)

Mattman85208
Mattman85208

Reputation: 2090

I'm using openpyxl version: 2.3.2

and this works for me:

for ws in workbook.worksheets:
    ws.sheet_view.zoomScale = 85
workbook.save(excelFile)

Upvotes: 23

Charlie Clark
Charlie Clark

Reputation: 19507

You cannot do this at the moment. See https://bitbucket.org/openpyxl/openpyxl/issue/262/set-the-zoom-of-a-sheet f

Upvotes: 2

Related Questions