Report text color

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

everytimer wrote at 2013-08-15 11:34:

I need to export a report and be able to change the color of some words. I've noticed that the Paragraph style is used when the report is actually being written, so I can't change it to the desired color, and then switch back to the default (black) because all will be written in black.

I've tried to convert HeaderStyles to a list instead of an array but that gave me a lot of troubles and finally a rare exception occurred. After that I just tried to increase HeaderStyles array to 25 (I will need 20 different colors + let intact the 5 default header style).

The problem is that if I set the array bigger than 9 a null reference exception occurs. I wonder if there is a better way of implementing this requirement and if not what can I do for being able to increase the array size of HeaderStyles to 25.


inside a loop:
  ParagraphStyle myStyle = new ParagraphStyle { BasedOn = reportStyle.DefaultStyle };
                               reportStyle.HeaderStyles[4 + myStyleSelector ] = myStyle ;
                              report.AddHeader(5 + myStyleSelector , "my text");
after:
   using (var w = new PdfReportWriter((dlg.FileName)))
                       {
                           w.WriteReport(report, reportStyle);
                           
                       }

objo wrote at 2013-08-15 17:05:

HeaderStyles should only be used for headers. We could change the array to a list, but normally 5 or 6 (html limit) should be enough.
To change the color on parts of a paragraph, we need to implement Inline elements with a Style property. I have added an issue:
https://oxyplot.codeplex.com/workitem/10071