Aspose.Cells If Smart Marker structure and correct syntax

Hey,

First, I would like to know, if there is any syntax for smart markers resembling “if”-statement in Aspose.Words? For instance, in Aspose.Words I could do this:

<<if [returnselected==0]>>No<<elseif [returnselected==1]>>Yes<<elseif [returnselected==-1]>> N/A 
<</if>>

Is there anything similar for Smart Markers?

Secondly, what is the correct way to reference all of the devices (and the fields) using Smart Markers? You can see the XML used to populate the tags in attachments. Untitled-1.zip (385 Bytes) Is it something like &=data.devicedata.devices.device.testPurchasePrice or something else?

@Suikero,

I am afraid, Smart Markers is a unique feature provided by Aspose.Cells which has its own grammar and style, so you cannot implement your desired task in your own way automatically in Smart Markers. You cannot use Smart Markers directly in if condition but you may make use of dynamic formulas in Smart Markers for the purpose, e.g., “&=&=IF(A{r}=…”, etc.

We will get back to you regarding your second query soon.

Your marker is right.

Okay, thanks a lot for the answers!

@Suikero,

You are welcome.

Hey, one more question.

I am trying to read XML-data to Excel file using smart markers in the template and using C# to process them, but for some reason I can only read the data inside the <data> tags. For example, inside the xml-file that I provided Untitled-1.zip, I cannot read testPurchasePrice -value at all.

However, I can read testaccount, testorder and testcecurrency-values. So nothing inside of the devicedata-block.

You can find the code I’m using below. Input is the XML-file coming in as a string. Is there anything wrong with my code?

            System.Data.DataSet dataSet = new System.Data.DataSet();
            using (TextReader reader = new StringReader(input))
            {
                dataSet.ReadXml(
                 XmlReader.Create(reader),
                 XmlReadMode.InferTypedSchema);

            }
            Workbook wb = new Workbook(tempSourceFile.Path);
            WorkbookDesigner designer = new WorkbookDesigner(wb);
            designer.SetDataSource(dataSet);
            designer.Process();
            wb.Save(tempSourceFile.Path);

@Suikero,

Thanks for the XML file.

I tested your scenario/case using your XML file with the following sample code using a template Excel file (having smart marker “&=data.devicedata.devices.device.testPurchasePrice” in A1 cell in the first worksheet) .
e.g.
Sample code:

            System.Data.DataSet dataSet = new System.Data.DataSet();
            using (TextReader reader = new StringReader("e:\\test2\\Untitled-1.xml"))
            {
                dataSet.ReadXml(System.Xml.XmlReader.Create(reader), XmlReadMode.InferTypedSchema);

            }
            Workbook wb = new Workbook("e:\\test2\\Bk_smartmarker_structures1.xlsx");
            WorkbookDesigner designer = new WorkbookDesigner(wb);
            designer.SetDataSource(dataSet);
            designer.Process();
            wb.Save("e:\\test2\\out1.xlsx");

I got an exception " Data at the root level is invalid. Line 1, position 1" on the following line of code:
dataSet.ReadXml(System.Xml.XmlReader.Create(reader), XmlReadMode.InferTypedSchema);

Could you please share a sample runnable code with template Excel file to reproduce the issue, we will check it soon.