logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
CPBOURG  
#1 Posted : Friday, January 11, 2019 4:17:44 PM(UTC)
CPBOURG

Rank: Advanced Member

Groups: Registered
Joined: 9/13/2018(UTC)
Posts: 41
Belgium
Location: Ottignies

Was thanked: 2 time(s) in 2 post(s)
Hi there,

I have a request from the users for conditional formatting on dates.

The report is about projects, and their start/end dates, and the status.

The idea would be that if the end date is over, and the project is still ongoing (not closed), the date should be displayed in red.

I found out using the cell script how to format the cells, but I'm stuck on the date comparison... (cell.Value <= Now() ???)

Can you please help?

Thank you in advance
Thomas
epf  
#2 Posted : Monday, January 14, 2019 7:21:08 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Cell script is the good place for conditional formatting.
In your cas I would suggest:
Code:
    if (! cell.IsTitle && cell.DateTimeValue < DateTime.Now) {
        cell.FinalCssStyle = "background:red;";
     }
CPBOURG  
#3 Posted : Monday, January 14, 2019 8:24:29 AM(UTC)
CPBOURG

Rank: Advanced Member

Groups: Registered
Joined: 9/13/2018(UTC)
Posts: 41
Belgium
Location: Ottignies

Was thanked: 2 time(s) in 2 post(s)
Thanks!

It worked fine on the date comparison.

Now that I added the comparison of the string part, it seems not to work.

Is there something like cell.StringValue I am supposed to use when comparing strings?

Thanks!
epf  
#4 Posted : Monday, January 14, 2019 10:20:07 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Read the documentation in comments:
cell.DisplayValue (type = string) is the display value
cell.DoubleValue (type = double?) is the cell value for numeric
cell.DateTimeValue (type = DateTime? ) is the cell value for date time

To customize your calculation and cell display, you can assign
cell.Value (type = object) is the cell value: string, double or DateTime

cell.Value can be casted as a string or you can use DisplayValue.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.