1

In NPrinting Designer (in the Pixel Perfect format) there is an option to use Conditional format which will color fonts/backgrounds according to a condition. This works for the 'rows' of a container/table but the same logic cannot be applied to the 'total' which is in a separate container/table.

That's why I am trying to solve the problem with the total using the script editor of NPrinting Designer.

Qlik has created a video where they demonstrate how you can output a table with top 10 rows using the following C# code:

Link: https://www.youtube.com/watch?v=iL-qmau233k

//C# code for printing the first 10 rows
using System.Drawing.Printing;

private int detailRowCount = 0;
private int topNRow = 20;

private void Detail_BeforePrint(object sender, PrintEventArgs e) 
{
        if(++detailRowCount > topNRow)
                e.Cancel = true;
}

I am not an expert in C# code at all but I have tried to use the same logic to achieve the conditional coloring of the total row:

using System.Drawing.Printing;

//C# code for printing conditional coloring/colorting based on values 

Color redColor = Color.FromArgb(255, 0, 0);
Color greenColor = Color.FromArgb(0, 255, 0);

private void ColorBackground(object sender, ColorEventArgs e) 
{
        if(e.CellValue > 0) 
        {
                e.Cell.ColorBackground = Color.redColor;
        }
        else if(e.CellValue <= 0) 
        {   
                e.Cell.ColorBackground = Color.greenColor;
        }
}

This is what I would like to achieve in pseudo-code:

Around 100 reports (imagine one for each region of a country).

When total > 0 Then color background of that container red

Else color background of that container green.

When I validate the code in the script editor of NPrinting Designer I get the following error:

The type or namespace name 'ColorEventArgs' could not be found (are you using a directive or an assembly reference?)

The error message probably makes sense but again as I am not familiar with C# and just using this as my last option I would like to know how I can move on from here.

Any ideas?

Saud
  • 480
  • 1
  • 9
  • 26
  • I found a post in the Qlik Community with C# code that changes the font and font color. But it is not based on any criteria. `private void richText1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { richText1.Font = new Font("Segoe UI", 20, FontStyle.Bold); richText1.ForeColor = Color.Blue; }`. Link: https://community.qlik.com/t5/Qlik-NPrinting-Discussions/Applying-font-formatting-in-PixelPerfect/m-p/14657 – Saud Oct 28 '19 at 14:04

0 Answers0