Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have done my best to search for existing content about my question and drawn a blank....
I am experimenting with PixelPerfect reports. This is the first PixelPerfect report I've worked on; I've read the introductory material available, which doesn't go into masses of detail.
My current goal is simply to bring in the results of a formula and apply some formatting to it (font and font size). My question, in short, is "I seem to have tried everything but it's not working - what am I missing?"
Here's all the extra info of what I've done:
Here's what my template looks like:
At the top of the Detail band is a panel - ignore that.
Below the panel is a Rich Text box referencing the 'ValueDollars' formula I've created. As you can see, I've chosen Segoe UI in 20pt as the font for this text box. I've actually chosen this font in multiple places - the main Font property seen to the left in the Property Grid, and also under the 'Formatting Rules' and 'Styles' parts, by clicking the [...] next to (Collection) and going through the dialog windows that come up. I confess I haven't yet fully understood the purpose of the Formatting Rules and Styles stuff, I'm just experimenting.
I then copied that text box - with all the formatting choices applied - and pasted just below, editing the contents to the word 'test' (not a reference to any Formula, Cell, or any other dynamic reference - just static text). So logically this has the exact same format as the box above it.
When I preview this report, or when I save, close, and run it as a task, here's what I get:
The $6.9 million number is the correct number - so the formula is working correctly. However you'll notice the font for the formula boxes is the default Times New Roman, and smaller. Whereas the copied static text box has correctly had Segoe UI 20pt applied.
I'm sure there's some other configuration property that I'm missing, but darned if I can find it...
Can anyone help point me in the right direction? Thanks in advance!
Hi Stuart,
Not sure why you are using a RichText control in the first place. You should use RichText to display RichText formatted strings (where each letter can potentially be a different colour, size, font etc.). You can use a Label control instead and set the font quite easily.
Having said that, if you want to stick with RichText, you can use script to format the control.
Example:
Lets say your RichText control has name richText1
You can add C# code in the control's BeforePrint event like this:
private void richText1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
richText1.Font = new Font("Segoe UI", 20, FontStyle.Bold);
//richText1.Font = new Font(richText1.Font, FontStyle.Italic);
richText1.ForeColor = Color.Blue;
}
Gives:
HTH - Daniel.
Can you show this ValueDollars formula?
Maybe if you set your formula like this? : =Text(YourFormula)
Thanks for the reply Carlos.
My ValueDollars formula is as follows:
text(money(round(sum({$<Year=, [Fiscal Year]=, Month=, [Fiscal Month]=, MonthNum=, [Fiscal Month Num]=, OrderTypeCategory-=$(NoDisposals)>} Value)),'$#,###,##0;($#,###,##0);nil'))
So I was already trying to coerce the formula result to text; I had originally not been using the text() function, and added it to see if it helped - but it didn't.
The specifics of the set analysis shouldn't be too relevant here, since I know the number being returned is the right one. I'm using money() inside text() because I do want the results to be shown in US standard currency format, with thousand separators etc. Stripping the formula back to just the sum() function without the outer functions does not make any difference to the resulting font.
Hi Stuart,
Not sure why you are using a RichText control in the first place. You should use RichText to display RichText formatted strings (where each letter can potentially be a different colour, size, font etc.). You can use a Label control instead and set the font quite easily.
Having said that, if you want to stick with RichText, you can use script to format the control.
Example:
Lets say your RichText control has name richText1
You can add C# code in the control's BeforePrint event like this:
private void richText1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
richText1.Font = new Font("Segoe UI", 20, FontStyle.Bold);
//richText1.Font = new Font(richText1.Font, FontStyle.Italic);
richText1.ForeColor = Color.Blue;
}
Gives:
HTH - Daniel.
Thank you Daniel. Your comment about labels vs rich text was the clue I needed: the only official mention of these (that I had found) hadn't quite made sense to me.
When I tried adding my formula onto a label, it immediately formatted correctly. This will actually work fine in my immediate use-case.
In general, I want to be able to use the power of a rich text box as well. You could think of my example above as a reduction to the simplest possible example of the problem - in some situations I will want to mix multiple fonts/sizes in a rich text box and include dynamic values from formulas, for which I think your script approach wouldn't work?
Thanks to your comment I've experimented further with how I use the rich text box and have found the root cause of my problem. Writing it here in case it helps someone in the future:
Wrong way (that I was doing):
Right way:
It seems the wrong way adds the second control as a separate entity bound to the first one somehow - so I had a Rich Text box and a Label in the same place, locked to each other (not two objects overlapping). Rather than the right way which just adds a square-bracketed reference to the formula into the sequence of characters within the text box.
(The 'wrong way' still works with a Label control, however.)
Perhaps somebody else can give a better explanation than me, but either way, the 'right way' always works so I'll be doing that from now on!
Daniel,
I have a requirement to change the font's style and color for substings in my report's table:
I've tried to use script and formatting rules, but was unable to achive the desired results.
And I could not find a reference guide or help topic for this case as well.
Will you be able to recomend a solution I can use?
Appreciate your help!
Regards,
Vlad
Hi @vladkomorov
There may be a very simplistic way to handle this. I will use the following line as an example.
Add 3 rich text boxes to build the following line
"Earnings received by members based on PAID AS OF date following report"
Align all three text boxes horizontally using the available alignment tools in the PXP editor so they appear as a single unified line. (layout and alignment in the PxP toolbar)
Use a conditional formatting rule to alter the appearance of text box 2 as needed.
There might be a scripted way to do this but our expert in that field is out on vacation
cc @ruggeropiccoli
Frank,
Thanks! Interesting idea, but creates additional complications in my case. I am loading these lines from one table and as you can see these records have different lenghts, and some of them are taking few lines:
so it will require the whole template re-design and I was hoping to avoid that.
It looks like the Script option should be a better solution, but I could not find any good reference how to handle it there...
Please let me know if you could suggest any other option....
VK
I've ping our in house expert on this but he is on vacation.
He is pretty great about responding to this complex type of request ie: if it's possible or not and how to to it if it is.
Hope you are doing well in your new gig!
Cheers...fs
cc @ruggeropiccoli
Hi,
Please avoid to add new requests to so old conversations. It is better to create a new one instead.
You can create a new field with HTML code in the source Qlik Sense app to format the part of the text you want to change. Then you have to refresh the connection cache and close and re-open the Designer. Drag and drop a Rich Text object in the correct details band. Then expand its Data Binding property -> HTML and select the new field with HTML code from the drop down list. HTML tags will be interpreted and related format applied. I tested with basic HTML tags and the PDF was correctly generated in my installation.
Best Regards,
Ruggero