SSRS Reporting Services - Bold Word in String

血红的双手。 提交于 2019-12-10 20:45:17

问题


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:

  1. Create three calculated fields in your dataset, within the report.

    1. LeftOfAuthor:

      =LEFT( Fields!BigString.Value , Instr( Fields!BigString.Value , Parameters!5aAuthor.Value) - 1 )

    2. Author:

      =Parameters!5aAuthor.Value

    3. RightOfAuthor:

      =RIGHT( Fields!BigString.Value , LEN(Fields!BigString.Value) - Instr( Fields!BigString.Value , Parameters!5aAuthor.Value) + LEN(Parameters!5aAuthor.Value) )

  2. 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.

  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!