Flexcel class object as a value

Hi,

Let's imagine we have a simple class, for instance

class Person {
public FirstName {get;set;}
public LastName {get;set;}
}

when generating report I'm able to do the following:

var owner = new Person();
var requester = new Person();
var report = new FlexCelReport();

report.SetValue("OwnerFirstName", owner.FirstName);
report.SetValue("OwnerLastName", owner.LastName);

report.SetValue("RequesterFirstName", requester.FirstName);
report.SetValue("RequesterLastName", requester.LastName);

After this I can use registered values in my report as <#OwnerFirstName>, etc.

But actually I want to something like this:
report.SetValue("Owner", owner); in code
and <#Owner.FirstName> in template

That doesn't work because seem like the FlexCel report variable doesn't support that or similar syntax.
So, the question is, are there any ways to get object field value from a template?

Thanks in advance


Hi,

This is an interesting idea, I am investigating how it could be done.
The main problem for implementing it is that we use the dot (".") to specify datasets, so if you write <#Owner.FirstName> FlexCel tries to locate a table "Owner", not a report variable. I'll have to look deeper to see if changing this wouldn't break existing reports.

In the meantime, as a workaround you could add a table instead of a report variable. You would do:

var owner = new List<Person>();
owner.Add(new Person());
report.AddTable("Owner", owner);

And then in the template, write
<#Owner.FirstName>

and also define a name owner covering the cells where all the <#Owner. ...> variables are.

This will allow you to use the "." syntax in the template, but has the drawback that you need to define a owner named range covering those variables. 

You might even use sub.subobjects this way, like <#Company.Owner.FirstName>

As said, I'll see if it is possible to add direct support for this, but you do have this workaround.


Wow!  I didn't expect "sub.subobjects" will work in tables because more simpler report variables don't support that.
Now I understand that FlexCel just treated the variable with "." as dataset.

The workaround is acceptable. Thanks for your help!

Hello Adrian,

Did you investigate is it possible to use dot syntax for report variables?

The workaround with datasets is hard to the end user, because of need to create a named range. And as data can appear in many different places, the named range is getting complicated.

The second workaround that I found is to use #dbvalue. (<#dbvalue(List;0;"ListItemData")> )
It's not required to use named range, but doesn't look user frienly.

Thanks in advance

Hi,

We are still looking at ti. A lot of work is going on right now with the 6.0 release, and I hope we get time to implement this, but I can't guarantee it.

Regards,
   Adrian. 

Hello Adrian,

Are there any news?

Sorry but not yet, and it will still take some time.


This feature is in our todo list, but currently we have xlsx conditional support as a maximum priority item, so we won't be able to look at much else until that is implemented. There are a couple of things more also with higher priority, but well, I guess that in a couple of months we'll get time to look at it again. This is a feature I really want to implement, it is just that we need to prioritize what most users are asking for.