views:

774

answers:

2

My users use Excel to come up with some ad-hoc lists of buildings we own. I'm building an InfoPath form to manage contracts on those buildings. I'm looking for a way to let my users specify the buildings they need in Excel, and paste that list into the InfoPath form Repeating Table control.

The table has multiple fields; the users would select the Building ID column in their spreadsheet, paste it into the Building ID field in the Repeating Table, and then the InfoPath form would look up the remaining building info from the datasource bound to the control, using the Building ID as the key.

The Repeating Table lookup part is currently working: the user can enter (by typing or pasting from Excel) a single Building ID, hit Tab, and the table looks up the rest of the info. Then they can insert a new row, and enter the second building ID, lather, rinse, repeat. This is fine for a handful of buildings -- but not for dozens or hundreds. So I'm looking for a way to let them paste in a list, and fill out the table from there.

If they can't paste directly into a Repeating Table, could I have them paste into a multiline Text control, and then parse that with an XPath expression? What would that XPath look like? One final limitation: no code-behind C# or VB -- we've decided for the moment that the logistics of deploying forms with code-behinds is too much for the current project.

Any help appreciated...

A: 

The only issue I see arising (mainly due to the fact that this solution can't involve codebehind) is the fact that there are no Infopath rules you can use to dynamically add additional nodes to a repeating group (which is what the repeating table is binding to.)

The only way to create additional records in a repeating table is for the user to manually press the "Insert additional row" tab at the bottom of the table.

I'd strongly recommend using codebehind, so a user could paste their tab-delimited excel data from the clipboard into a box; have it parsed serverside; and use that data along with a routine to access the MainDataSource of the form, and add the additional rows that way.

Gurdas Nijor
Yep, I was afraid of that; I couldn't find any way to add rows without either the user clicking a button or by using codebehind. I found some articles about automating the deployment process when codebehinds are used, but they look fairly complicated. We might tackle that on the next project. In the meantime, I think I'll come up with an alternate, like saving the user's Excel list to a data source like a SharePoint list or SQL Server table, and having the form read from that. Thanks for confirming!
Val
A: 

If you extract the source files from infopath, one of the documents will be the template.xml file. this will hold the data for your infopath form. use an excel macro to open the template as an xml document and add the data from the excel spreadsheet. you can then allow the user to open the file themselves or open it for them. Just a way to get around not having codebehind.

Nathan Fisher
Well, I won't downvote this because it's technically a valid solution -- but from a usability point of view it's totally impractical. When I find myself turning to solutions like this, I think it's a sign I'm using the wrong technology. Rather than go down a path like this, it's time to either abandon the feature, find a completely different way to accomplish the goal using the present technology, or implement the user-requested feature directly using a different technology.
Val