问题
Publication - How to bold author name from within a string? It would be something like this if 1 value was returned but it is a string (=iif(Fields!Author.Value = Parameters!5aAuthor.Value, "Bold", "Normal"). Example: Authors + Year + Title + Journal + PMCID . Authors = Miter, MH, Owens, R, Thompson etc… I only want to bold the Author that matches the parameter value. I need to break apart the string – find the author – bold it – and leave the others as default. Like an array….
Problems:
Author has to be displayed in a certain order. Meaning the author might be displayed 1st or 3rd or 5th or whatever. Below is what is required.
I can create this as a view but I still have the same issue of bolding author.
Example - Miter, M.H., Owens, R., Thompson, P., and Berg, L., 2004, "Insulin Treatment of Diabetic Rats," J. Comp. Neurol., 373:350-378.
Brown, B. and Jones J., 2005, "Repeated Sequences in Drosophila," J. Mol. Biol., 242:503-510. Corman, T., Walker, J.D., and Brown, B., 2006, "Ontogeny of Tolerance to Alloantigens," Am. J. Anat., 146:156.
Samuels, J. and Peters M., 2009, "Molecular Analysis of RNA Viruses," Molecular Biology of the Cell, Vol. 11, 12-18. PMCID: PMC2583929
Each 2 Lines (example) would go in 1 text box...
回答1:
You are exactly right with your general approach:
I need to break apart the string – find the author – bold it – and leave the others as default. Like an array….
Sounds like you want to do this at the report level instead of in SQL.
If you are using SSRS 2008 or later, where you can use placeholders, then this is how I would accomplish this:
Create three calculated fields in your dataset, within the report.
LeftOfAuthor:
=LEFT( Fields!BigString.Value , Instr( Fields!BigString.Value , Parameters!5aAuthor.Value) - 1 )
Author:
=Parameters!5aAuthor.Value
RightOfAuthor:
=RIGHT( Fields!BigString.Value , LEN(Fields!BigString.Value) - Instr( Fields!BigString.Value , Parameters!5aAuthor.Value) + LEN(Parameters!5aAuthor.Value) )
Now put three placeholders into the text cell you need this displayed within. Set each to refer to one of these calculated fields, in order.
- Select the middle placeholder (for Author) and bold it.
The formulas above presume that the author name has an exact match somewhere in the field. You'll need to add error handling if it might not be. They were not tested in any way, so may need some tweaking.
Some alternate approaches include breaking the string up in SQL and/or enconding the string with HTML <b></b>
tags for display, then setting SSRS to display it as HTML.
来源:https://stackoverflow.com/questions/14162687/ssrs-reporting-services-bold-word-in-string