Smart Marker


#1

I hope someone can help me with this. We are new to Aspose Excel and want to use the smart marker technique to produce reports. I read a few blogs but was unable to find out how I can group data.

Here is an example of what I need.

Product Customer Total Orders

widget1 company1 10

company2 20

company3 30

Total for Widget1 60

widget2 company4 5

company5 15

Total for widget2 20

Grant total 80

The number of products listed will vary depending on user selections


#2

For you case, I think you can create a DataTable to include all data. Then you create different DataViews based on different products. These DataViews can have different data source names.

For example, you can set the following smart markers in your file:

&=Product1.ProductName &=Product1.CustomerName &=Product1.Orders

&=Product2.ProductName &=Product2.CustomerName &=Product2.Orders

&=Product3.ProductName &=Product3.CustomerName &=Product3.Orders

Then in your code:

designer.SetDataSource("Product1", dataview1);

designer.SetDataSource("Product2", dataview2);

designer.SetDataSource("Product3", dataview3);


#3

I though of doing that too. The problem is that I don’t know how many products I will have at run time.


#4

You can also set smart markers at run time. Before processing, you can set smart markers based on number of products.


#5

This sounds like it will do the trick. How do you set Smart Tags at run time?

Can you send me samples?

Thanks


#6

Just put them as normal strings. Such as:

ExcelDesigner designer = new ExcelDesigner();

Cells cells = designer.Excel.Worksheets[0].Cells;

cells["A1"].PutValue("&=[Order Details].OrderID");

....

designer.SetDataSource();

designer.Process();