cancel
Showing results for 
Search instead for 
Did you mean: 

set style for reports

Former Member
0 Kudos

Hello

i need to find a way to give a format to objects inside my reports, in a way similar to css.

Actually i export my reports in the code behind of my page, i wish to set the report sytle (font size and type, color, backgroung and so on). I've tried to use the setcssclass method in the code behind of the page that export the pdf without success :


the page:

<head id="Head1" runat="server">
<title></title>
<style type="text/css" runat="server" id="stile">
    h1
    {
    background-color:Aqua;
    border-color:Black;
    color:Black;
    font-family:Arial;
    font-weight:bold;
    font-style:italic;
    }
</style>
</head>

the code behind

report.SetCssClass(ObjectScope.PageHeaderSections,"h1")
Dim oStream As System.IO.MemoryStream
oStream = DirectCast(report.ExportToStream( _
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat), System.IO.MemoryStream)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.BinaryWrite(oStream.ToArray())

I wish to remark i don't use crystalreportviewer and the above code print the file directly inside the browser.

the questions are:

1. does the above code should work and i'm doing something wrong or that approach is completly wrong and will never work? If it's a correct approach, why the stye doesn't get applied?

2. if that's not the rigth way to do this thing what tool should i use? formatting formulas? do them allow me to format large pieces of report at the same time like css do in html ? Can you provide me links to examples or tutorial.

i'd like to avoid to set font size,type , line thickness or colors for each item in the report, so any hint will be greatly appreciated

thank you in advance

Stefano

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello, Stefano;

The code you are using is only formatting the HTML page and not affecting the report object.

To do that you would need to use the Crystal Reports SDK and that would include formatting options.

You are correct, you can use formatting formula for objects. You will want to test your results in the designer first. It will have to work the way you expect there.

You may be able to do create some generic formula that will work on larger groups.

e.g. @Format_Color

You could use this formula for lines and fonts that you needed the same color and at runtime pass in the color needed:

Report.DataDefinition.FormulaFields.Item("Format_Color").Text = crBlue

Then use this formula when formatting all the fields you where you want blue options for Font or Underlines as an example.

Another option is to actually add formatting at runtime using the Report Creation API properties of the Report Application Server SDK (RAS).

You can look for more ideas in the [Developer's Library|http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm]. Look at "[New APIs for enhanced report customization|http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/RAS_SDK/rassdk_net_doc/doc/rassdk_net_doc/html/Whats_New_RAS2.html#1022964]".

Once the changes are made in the report object it should export to .pdf as you expect.

Elaine

Former Member
0 Kudos

Hello Elaine

thank you for your answer. I'll submit you another problem. I use a couple of report to print mail labels, i've set the paper size to "monarch envelope" in the printer settings of the report at design time: the user needs to send mail to n different addresses, and i wish to print aech address on a different page. So i use the report export method to create a pdf and i print it directly in the browser using the response output stream. When the browser shows the report, the paper size,orientation etc are correct , but when i try to print it through the adobe reader plugin of ie7, the printer dialog is still set on "A4" paper size. I've tried to set up printoptions to wished options at runtime but the dialog doesn't see theese settings.

Does Acrobat bypass report settings? If so i'll have to find an alternative way to print this kind of report.

There's a way to do the above thing?

thank you in advance

Stefano

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello, Stefano;

I would be glad to answer your question for you but it needs to be in a new Message.

From the "Rules of Engagement":

- Only One Question Per Posting

For each question that you have, make a separate posting. Don't ask multiple questions in one posting, this is confusing for people and might not get answered, since the subject line does not reflect all your problems. If a new and unrelated question comes up during a thread, start a new thread.

It makes sense because a thread gets very long and confusing for anyone else trying to find an answer to the same question.

Elaine