Open Excel File with Python


Hi All,

Quick question. How do I open a particular Excel file using python? Don’t want to write or read the info, just open the file?

Thanks in advance!


Why exactly do you want to use Python code for that?

You can simply use the Excel.ReadFromFile node to read data from an Excel file and an Excel file will always open to let Dynamo do so.

A script like the following should do the job:


Hi @PauLtus, I’d like to use it first, to know how can I call excel files from python and also because it is a part of a larger python code.

The example you mentioned it is what I want but using only python. Is it possible?

Thanks in advance!



Well, you probably can.

But in that case maybe you can just load in the file in a similar sense to as you’d do with other inputs:

Following that, I’m an absolute Python amateur.
Might be a case where you’d just want to ask it on a Python forum.


Thanks @PauLtus


It’s possible! If you want to background-open the Excel file for editing (as part of your Python script) you can double-click on Konrad’s Write Excel node in the Bumblebee package to read through the process.

I have no idea about your level of experience - it’s not for beginners. Also, check out the Microsoft Office Interop library for Excel. If this process doesn’t make sense to you, I would just suggest using Dynamo.


Thanks I managed to do this (the path to the excel file was stored in my project information):

import clr

from Autodesk.Revit.DB import *
import Autodesk

import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' )
from Microsoft.Office.Interop import Excel
from System.Runtime.InteropServices import Marshal

doc = DocumentManager.Instance.CurrentDBDocument
ruta = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ProjectInformation).ToElements()[0].LookupParameter('RUTA PLANILLA MUROS').AsString()

#abrir el libro de excel y extrae las columans relevantes
ex = Excel.ApplicationClass()
ex.Visible = True

workbook = ex.Workbooks.Open(ruta)

OUT = 'Listo!'