Reading Excel Information

There’s a weird thing happening with grabbing some info from an excel file.
In R2024 everything works fine:

In R2025 I just get null for some reason:

I have the latest scripts installed and Iron Python 2.7…Any ideas?

In Revit 2025, when I need to import from Excel, I do it this way. I’m not sure if it comes from a Node package or if it’s built into Dynamo, but I’ve also added an image related to it.


resim

Can’t really use that in my script since I need the sheet names from the document to push them into a Data Shapes select window…

image

hi,

here a solution using Python and OpenXML

import clr
import sys
import System
from System import Array
from System.Collections.Generic import *

clr.AddReference('DocumentFormat.OpenXml')
import DocumentFormat
from DocumentFormat.OpenXml import *
from DocumentFormat.OpenXml.Packaging import *
from DocumentFormat.OpenXml.Spreadsheet import *


def get_ExcelSheetsName(filepath):
    fileStream = System.IO.FileStream(filepath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)
    spreadsheetDoc = SpreadsheetDocument.Open(fileStream, False)
    lst_sheetsName = [s.Name.Value for s in spreadsheetDoc.WorkbookPart.Workbook.Sheets]
    return lst_sheetsName


file_path = IN[0]
OUT = get_ExcelSheetsName(file_path)
6 Likes

Thank you for that, unfortunately it does not work with the Data Shape Inputs.
image

input must be a string (file path), which data shape node did you use as input?

These ones.

This is just baffling…

When I retrieve the data by specifying the index from the User Inputs output, the Python script does not give an error.

1 Like

that’s a good shout, thank you for that :slight_smile:

The lower branch appears to be passing a string, which means the input needs to be handled differently.