There is something which is amiss here. The code you sent me had no parameters or variables. However, the plans you posted has:
<ColumnReference Column="@inWorksheetPk" ParameterCompiledValue="'87fbac050a07009a3aa818b91059edc9'" ParameterRuntimeValue="'87fbac050a07009a3aa818b91059edc9'" />
<ColumnReference Column="@inExcelLibraryId" ParameterCompiledValue="(24.)" ParameterRuntimeValue="(24.)" />
A quick glance indicates that the plans are for a similar query to the queries you mailed me, so I guess you played around.
Nevertheless, it is difficult to help with conflicting information.
When you ran the code with parameters/variables, did you get a noticeable difference in performance? Or do you only get that when you run without parameters? What difference are we talking about?
Can you post the code to the user-defined function? (It's much better to post the code here than mailing it to individuals, so that others can join in.)
Erland Sommarskog, SQL Server MVP, www.sommarskog.se