How to use loop for Excel.ReadFromFile



I have a Excel workbook with different sheets. I would like to use the Excel.ReadFromFile and run my script for each of these sheets. Is there a way to this?

So it should take the first sheet name “Building A” and run the script… then the next … then the last…


You’re close. You just need to feed the sheet names into the node as a list.

ETA: You’re code block has three outputs, one for each sheet. You are “wired” to the “Building B” output, so that’s all that is input to the Excel node.


This should just work fine as an input as well.


Thank you to both of you. However I need to assign the Sheet name value to my elements in the end of the script. So that is why it should be Sheet 1 run script to the end… then Sheet 2 run script to the end etc. Is this possible? I need to use the Sheet name in ‘Element.SetParameterByName’ :


What’s going into that Sheetname Code Block?
Whatever it is, it’s exactly the result is exactly the same as not letting it go through that code block, and if it isn’t a string, the Element.SetParameterByName node won’t take it.


Its just the name of the sheet going into Sheetname Code Block.


Actually running repeatedly isn’t advisable here. Instead you need to set your graph up to use lists instead of single elements. The first list of elements selected which use sheet 1 can receive the value sheet 1 from the original sheet name input. The second list of elements can receive sheet 2, and so on. Look into list levels and lacing to help towards this end.