ChrisP Posted January 24, 2012 Share Posted January 24, 2012 Hello - I am completely new to the world of HTML but need some help with what I'm hoping will be a very simple solution. Advanced conditional formatting in Crystal Reports requires some HTML code to be added. In a nutshell I am trying to make the word 'Fox' appear in red, bold font with a yellow background - the word fox is just one word that will appear in a whole text string. I currently have the following code that produces the text in red and bold but I cannot get the yellow background to work. Some of the syntax below may appear weird but that may just be the Crystal requirement. Hope this makes sense? StringVar SearchText := "fox";StringVar Htm1 := "<b><font color='red'>";StringVar Htm2 := "</font>"; Link to comment Share on other sites More sharing options...
Ingolme Posted January 24, 2012 Share Posted January 24, 2012 I don't recognize this language. I guess it's what you're calling "Crystal"You forgot a closing <b> tag, and <font> is deprecated. You should use CSS instead: StringVar Htm1 := "<span style='font-weight: bold; color: red; background-color: yellow'>";StringVar Htm2 := "</span>">; Link to comment Share on other sites More sharing options...
ChrisP Posted January 24, 2012 Author Share Posted January 24, 2012 Thanks for that. As I mentioned above, I am very, very new to this so will look at the CSS option although what you suggested after a bit of tweaking only produced red font not bold and yellow highlight (background). The code below is at least giving me bold and red so it's a start and if anyone knows if it's possible to extend that to include yellow highlight (background colour) then that would be just great. Thanks StringVar SearchText := "fox";StringVar Htm1 := "<b><font color='red'>";StringVar Htm2 := "</b></font>"; Link to comment Share on other sites More sharing options...
Ingolme Posted January 24, 2012 Share Posted January 24, 2012 The code I gave you will do it. There's no HTML that will give you a background color to inline text. CSS is required to style pages. Your closing </b> tag should be after the closing </font> tag. Link to comment Share on other sites More sharing options...
ChrisP Posted January 24, 2012 Author Share Posted January 24, 2012 Thanks for your help. I do at least have a font that differs in that it's bold and a different colour. I'll live with that I think as the Crystal syntax can be very 'fussy'! Link to comment Share on other sites More sharing options...
Ingolme Posted January 24, 2012 Share Posted January 24, 2012 It should accept anything inside a string. Just use the <span> as I showed you and there should be no problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.