Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to add HTML-formatted field to report...

Status
Not open for further replies.

roerunner

Programmer
Feb 1, 2006
10
US
CR Version: Crystal Reports 10 for Visual Studio .NET

I am trying to render a field on my report that will have HTML formatting in it. I added a parameter field to my report and then went into the Format...> Paragraph > Text Interpretation area. The only options listed are None and RTF Text. When I go into the x+2 formula editor I type in "crHTMLText" (w/o quotes) into the editor area. When the report is generated, the parameter text value is set to a string that contains HTML tags, but when the report displays, the field does not display. When I take out the "crHTMLText" formula it does work, so I know that the field's value is getting set properly.

Any help would be appreciated!



-----
Kelly
 
What is the data type of the field in question (at the database level)?

Speaking of which...what DB? Oracle? MSSQL? DB2? MySQL? ???

-- Jason
"It's Just Ones and Zeros
 
I'm actually just hard-coding a value for the field in code -- "<b>test</b>".

-----
Kelly
 
I don't think CR will handle that. The field format properties are based on the actual data type of the field at the DB level. (number, varchar, date, etc).

But per the help file.....

Text interpretation
Use this list to select the type of pre-formatted data (string or memo fields only) or text you are inserting in a field. Crystal Reports extracts information about the font, size, style, color, and paragraph and displays the data or text with the specified attributes.

Your choices are:

"none" to interpret the string or memo field or imported text as if it contains plain text.
"RTF Text" to interpret the string or memo field or imported text as if it contains Rich Text Format data.
"HTML Text" to interpret the string or memo field or imported text as if it contains HTML data.
The supported HTML tags are:

html
body
div (causes a paragraph break)
tr (causes only a paragraph break; does not preserve column structure of a table)
span
font
p (causes a paragraph break)
br (causes a paragraph break)
h1 (causes a paragraph break, makes the font bold & twice default size)
h2 (causes a paragraph break, makes the font bold & 1.5 times default size)
h3 (causes a paragraph break, makes the font bold & 9/8 default size)
h4 (causes a paragraph break, makes the font bold)
h5 (causes a paragraph break, makes the font bold & 5/6 default size)
h6 (causes a paragraph break, makes the font bold & 5/8 default size)
center
big (increases font size by 2 points)
small (decreases font size by 2 points if it's 8 points or larger)
b
i
s
strike
u
The supported attributes are:

align
face
size
color
style
font-family
font-size
font-style
font-weight

-- Jason
"It's Just Ones and Zeros
 
Crystal does handle this, from at least c8.5 and new. Here is a sample formula I did for a customer:

Code:
"<strong>" + "Hello, " + "</strong>" + " today is: " + totext(currentdate,"MM/dd/yyyy")

What I have never found anywhere is a list of the supported HTML tags. The use of <b> does nothing, you must use <strong>. I would love to get a list of this.


Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Let me clarify...I know that CR will support HTML formatting in FIELDS. I, myself, have numerous text (varchar) fields in my reports that have the HTML text interpretation applied.

What I was (am) unsure about is trying to apply that formatting to a hard-coded value (field).

As far the list of tags is concered see my previous post (from the help file). This may be all CR commits to supporting but I know I have used some additional tags.

-- Jason
"It's Just Ones and Zeros
 
dgillz,

Re <strong> vs <b>, my experience is exactly the opposite of yours - <strong> does nothing but <b> works.

Peter
 
Frank,

In a CRYSTAL FORMULA <b> works?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Brian,

Can you post your formula? I cannot get this to work in Crystal 8.5 or in XI.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Sure.

"<b>This should be bold.</b> and <strong>this part should be Strong</strong>"



~Brian
 
Brian,

I cut and pasted exactly from your post, and tested in v8.5 and XI R2. Works in neither version.

What could be wrong?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
dgillz,

In Crystal 10 Help, if I go to Index Tab and type:
'Paragraph Formatting tab',
it gave me a list of support html tags.
<b> works for me but not <strong>

Andy
 
I think I need to explain my scenario in more detail....thanks to all who have responded thus far!

The CR version I am using: Crystal Reports 10 for Visual Studio .NET

I have been playing around and now have a formula field to represent the data I want to format as HTML.

Database value = Oakton Study <strong>strong text</strong> <b>bold text</b>
Formula = {NetworkBid.ProjectName}

When I display the report as-is, without changing ANY formatting settings on this formula field, the report displays the following:

Output = Oakton Study <strong>strong text</strong> <b>bold text</b>

Since I hadn't made any changes to the format settings of the formula field, this makes sense.

So, when I go to make format changes so that the HTML formatting will be interpreted as such, I do the following:

1. Right-click on the formula field in the report and select Format... to bring up the Format Editor
2. Click on the Paragraph tab
3. In the Text Interpretation section, there is the Text Interpretation dropdown list. The ONLY options I have to select from are None and RTF Text. I keep it as None.
4. So, I click on the x+2 button to bring up the formula editor.
5. I type in the following (it shows up as a constant in the Text Interpretation section in the list of functions):

crHTMLText

6. I click on save and the close to save my changes.


When I re-run the report, my formula field does not display anything now. Nothing at all.

Output = NULL

Could it be that my version of CR (for .NET) does not support HTML-formatted data? Is there something else I need to do?

Thanks!!!


-----
Kelly
 
I think if it is not showing up as an option in the dropdown, that it must not be supported. I did a test taking the same steps as you with CR XI, and it works.

Don, I can use <b> but not <strong> for bolding.

-LB
 
LB and Brian,

As I mentioned, I cut and pasted Brian's formula and it did not work. I however did not know I had to format the field for HTML interpretation. Once I did that, it works fine.

<strong> also works, but you have to enclose <strong> in quotes. Paste this into your formula editor and it works from at least v8.5 and newer:

Code:
"<strong>" + "Hello, " + "</strong>" + " today is: " + totext(currentdate,"MM/dd/yyyy")

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If the phone doesn't ring, it's me".....Jimmy Buffet
 
dgillz,

Sorry I did not reply earlier; I was away for awhile but I see several others have chimed in.

Yes, the tags have to be enclosed in quotes and the field set for HTML interpretation.

Your example still does not work for me in CR XI but changing "<strong>" and "</strong>" to "<b>" and "</b>" works.

Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top