Tips, Tricks, and FAQs
Avoid Excel Cell Limits: Cut Long Content
Excel has certain limitations of the content, one of which is that a cell cannot contain more than 32767 characters. This will cause problems when your template exports description field too, which may contain longer text than this limit.
To fix this, the description should be abbreviated during export. For example,
${StringUtils:abbreviate(items.description, 1000)}

If this limit is exceeded, Excel will report a Repaired Records: String properties from /xl/sharedStrings.xml part (Strings) error when opening the result Excel file, indicating such a problem.
Exporting the Description and other Wiki content as Wiki source
When the Description field or other Wiki-type field is exported to Excel, the Excel export contains the wiki source instead of the same output shown inside Codebeamer. For example:
When exporting content (for example, the description of a bug) from codebeamer to Excel, the content is exported to Excel as its wiki source. This means that formatting such as hyperlinks, bold text, italic text, etc. is not kept. This is because Excel cannot display full HTML content or Rich Text formatting.
Text exported from the wiki to Excel is plain text that includes Rich Text tags. For example, the Rich Text tag for bold text is a __double underscore__. This means that when exporting text that appears as bold text on the wiki, the exported text is shown enclosed in double underscores in Excel: __bold text__.
If __bold text__ is imported back to codebeamer, it is shown as bold text. This simplifies "roundtrip" exporting (from codebeamer, to Excel, then back to codebeamer).
Converting Exported Content to Plain Text Using a Groovy script
If you want to export codebeamer content to Excel without Rich Text tags, the text must be converted. The following Groovy script converts exported text to plain text, without Rich Text tags:
org.apache.commons.text.StringEscapeUtils.unescapeHtml4(textFormatter.formatAsText(...))
Specifically, the above script includes two parts:
textFormatter.formatAsText(...)
and
org.apache.commons.text.StringEscapeUtils.unescapeHtml4(...)
The first part of the script (textFormatter.formatAsText(...)) does the following:
1. It renders the wiki to HTML.
2. It converts the HTML to plain text by removing HTML tags. For example, <b>bold</b> is converted to bold.
3. The converted text is escaped using HTML4 escaping. This is done to avoid any XSS problems, since this text is typically used on WEB pages.
As a result of HTML4 escaping, certain artifacts can appear in the converted text. For example, the script converts " to &quot, since &quot is the equivalent HTML entity of ".
The second part of the script (org.apache.commons.text.StringEscapeUtils.unescapeHtml4(...)) unescapes the text, which means it undoes the escaping in the last step of the first script. For example, it converts &quot back to ".
Exporting Codebeamer Content Using Microsoft Word
Microsoft Word can display full HTML content or Rich Text formatting. When exporting content from the wiki using Word, the output content matches the text inside codebeamer.
Using Regular Expressions
Regular expressions (Regexp) is a tool that you may want to use in Excel templates. For example, you want to extract the domain name from the email of the user who has reported issues. The following users/emails have reported issues:
zluspai@javaforge.com

zoltan.luspai@intland.com
You want to get the domain name in a cell like javaforge or intland should be extracted, so a report can be made which tells how many bug reports there grouped by the companies. So the result should be:
javaforge

intland
You can then use Regexp and the next Groovy script, which extracts the domain part:
<cb:groovy template="false" silent="false"> email = item.submitter.email; domainRegexp = /@(.*?)\./; matcher= (email =~ domainRegexp); return matcher[0][1];</cb:groovy>
Using this method works well but can be complex. An alternative is to use a Regexp:findFirst() custom function, which can extract the first match of a Regexp. This produces the same result:
${Regexp:findFirst(item.submitter.email, "@(.*?)\.", "$1")}

The Regexp:findFirst() function will accept the following parameters:
1st parameter is the input String to extract value from.
2nd parameter is the Regexp to find in the input string.
3rd parameter is optional and contains the expression that tells what to extract. The $0 text will extract the complete match, the $1 will extract the 1st group from regexp, and so on.
Additionally, the Regexp:findAll() function is available and works similarly to the find First method, yet scans for all matches, and puts the results to a List (of Strings).
Was this helpful?