calculating a formula with cell from XML file

K

Katayon

I have a textbox which I would like to show the result of a particular
calculation.
The calculation should include a value from a cell in an XML file which has
been included as a secondary data connection.

In the properties of the textbox, I select the f(x) option to create a
forumla, from there I click "Insert Field or Group" and then I access the
secondary data connection. I expand all the folders, however I am not able
to see a list of cells.

How can I specify a particular cell value from an XML file to be used in the
forumla?

(perhaps does my xml file have to formated a particular way?)

Thank you,
Katayon
 
S

Scott L. Heim [MSFT]

Hi Katayon,

I am able to get this to work as you need using an XML file setup as
follows:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<nums>
<nextnum>71</nextnum>
</nums>
</root>

Now I had created this for another sample so the node names are probably
odd for this scenario but when I add this as a data source, I can use the
"nextnum" node in the formula for my text box and the calculation works as
expected.

I hope this helps!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Katayon

Hi Scott,

Thanks for the response. This particular issue has really stoped my work on
the file and I have not been able to find the solution anywhere and it's very
important that I get it resolved right away.

I am not sure I understand your suggestion below, and please bare with me.
My XML file is actually just an excel spreadsheet that I saved as an XML file
in order to be able to use it as a data connection in the InfoPath file. The
simple spreadsheet just has items and a price grid.

I would like the Infopath document to use particular cell values to
calculate with in a formula. I am not sure from your suggestion below how I
can incorporate the code in the XML file and get the InfoPath file to look at
the cell number (i.e. C5) and it's value (i.e. 56) that I specifiy in the
forumla. I think you are suggesting that this needs to be programmed using
VBA editor in the XML file?

Thanks again for your help!

Katayon
 
S

Scott L. Heim [MSFT]

Hi Katayon,

In order to use your file, InfoPath must interpret the file as "XML Nodes."
There is no way for it to recognize "cells" like you would see in Excel.

Now, I have not attempted to take an Excel file and save this as an XML
file for use in InfoPath so I am unsure of what the result would be;
however, the sample I provided in my last post does not use custom script
whatsoever - I simply added an expression as the "default value" for my
text box. (If you notice, a text box has a Default Value property and there
is an "expression builder" button next to this property...this is what I
used.)

I hope this helps!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top