This is a migrated thread and some comments may be shown as answers.

Deploying with external stylesheet

15 Answers 357 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
rh
Top achievements
Rank 1
rh asked on 27 Aug 2007, 03:51 AM
I used an external stylesheet on my first report. Figured I'd start building one up for the rest of my reports. However, when I deployed to my test environment I get an error because the report is trying to reference the stylesheet in the directory it sits in on my development machine. The directory schemes are different on dev and test/prod. How do you properly use an external stylesheet that can be deployed to a different directory scheme than the development machine?

15 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 27 Aug 2007, 02:22 PM
Hello rh,

In the current version, there is a slight limitation to the way you can load external style sheets. Currently, you can load them form a file only, but in a future version we will provide functionality to load external style sheets from a resource stream and then you will be able to embed the .xml files in your project's resources.

But for now, we propose the following solution:

1. Decide where on the production machine you will store the external style sheet file.
2. After the InitializeComponent method call in the report's constructor add the following code:

            string fileName = <<path to the style sheet file on production machine>>;
            FileInfo file = new FileInfo(fileName);
            if (file.Exists)
            {
                //this means we are on the production machine
                this.ExternalStyles.Clear();
                this.ExternalStyles.Add(fileName);
            }

If you do not want to hard-code the file path in your reports, you can always use the app.config or web.config file to define it there.

This code will check whether the file exists or not. If your are on your development machine, it will not exist and nothing will happen. But if you are on the production machine, it will be found and the ExternalStyles property of the report will be set accordingly. We hope that this will work for you. Feel free to contact us again if something goes wrong.

Best wishes,
Rossen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
MiroslavStantic
Top achievements
Rank 1
answered on 04 Feb 2008, 09:53 AM

If I put the suggested code after InitializeComponent in the reports constructor I still get the same error because the error is generated in InitializeComponent procedure.

This is my code:

 Public Sub New()
  InitializeComponent()

  Dim fileName As String = LISINReports.My.MySettings.Default.StyleSheetFileName
  Dim file As System.IO.FileInfo = New System.IO.FileInfo(fileName)
  If file.Exists Then
   'this means we are on the production machine
   Me.ExternalStyles.Clear()
   Me.ExternalStyles.Add(fileName)
  End If
 End Sub

Any suggestions?

Thanks

Miroslav

0
Rossen Hristov
Telerik team
answered on 04 Feb 2008, 10:42 AM
Hi Miroslav Stantic,

What kind of error are you getting in the InitializeComponent call? Can you send us the stack-trace and the whole report if possible.

If the error is caused because the file for the external style sheet can not be found, then you should remove that code (reset the ExternalStyles property of the Report from the report designer), since you mentioned that you will be loading the external style sheet after the InitializeComponent call. Since the external style sheet will be loaded programmatically, you do not need to load it in the InitializeComponent method (design-time). If that is not the case, please send us your project and we will examine it to locate the problem.

Regards,
Ross
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
MiroslavStantic
Top achievements
Rank 1
answered on 04 Feb 2008, 10:47 AM
Thanks for your quick response.

That is exactly what I did. I removed the external style sheet from the report after designing the report and set it programmatically. It works.

I wanted to avoid removal of external style sheet from the report though.

Miroslav
0
Rossen Hristov
Telerik team
answered on 04 Feb 2008, 02:29 PM
Hi Miroslav Stantic,

Unfortunately that is the only way to do it in the current version of the product. We will think about what can be done to alleviate the problem in a case like yours. We apologize for the inconvenience.

All the best,
Ross
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
rh
Top achievements
Rank 1
answered on 12 May 2008, 12:10 AM
Hopefully you guys can make it so it doesn't require the external stylesheets to be in the same directory path as on the dev machine sooner than later because until then external stylesheets are completely useless and, IMO, should be removed from the product so that people don't go down the painful road of using them only to find out they are useless once deployed to qa/prod environments.
0
Rossen Hristov
Telerik team
answered on 13 May 2008, 01:14 PM
Hi rh,

We are currently working on that functionality. We have plans to implement external styles with relative paths. Style-sheet XML files will have to be a part of your Visual Studio project and the developer will need to set the "Copy to Output Directory" property. Is this a feasible solution in your case?  If not, do you have something specific in mind on how the external styles should behave?

We are still gathering ideas how to make external styles more user-friendly and easy to use for our customers, so if you have any suggestions, we would be very glad to hear them. The architecture of your project is also interesting for us, i.e. what kind of projects do you have and where do you intend to keep the external style-sheet files, etc. Anything else that you can think of would also be appreciated. Thank you in advance.

All the best,
Ross
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
rh
Top achievements
Rank 1
answered on 19 May 2008, 03:32 AM
I have a single assembly that houses all of my reports. My goal would be to be able to reuse stylesheets across the individual reports which is why the external stylesheets was interesting. A couple of ideas I have are:

During the build process copy the external stylesheets to the assembly resources and then at run time get the external stylesheets from the assembly resources rather than a physical file on the disk.

Store the external styles in the resources up front and just skip the file based approach.

The downside to these approaches is that it limits the reuse to a single assembly. To get around this maybe the discovery process for the external styles could search all assemblies referenced by the project. This way if somebody wanted to create a library of styles to share across assemblies they could create a "resource assembly" to house the stylesheets and then reference that assembly from multiple report libraries.
0
Rossen Hristov
Telerik team
answered on 20 May 2008, 11:15 AM
Hello rh,

Thank you for your feedback.

For the next version we will try to make external style-sheets much more versatile. Our intent is to have functionality allowing external style-sheets to be loaded from a file path (absolute or relative), from URL, by resource name as an embedded project resource, or from a .NET Stream. In this way we want to cover all possible scenarios.

We hope that this will address your needs in particular as well.

Best wishes,
Ross
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
AgJeff
Top achievements
Rank 1
answered on 13 Mar 2009, 08:03 PM
We have styles defined in an external stylesheet that look fine in the designer and in the preview but when added to an ASP.NET website project the report renders, the images included as resources also render fine but the external stylesheet is not applied - oddly the background images show up but none of the font stylings are applied. I have followed the instructions carefully but have never successfully gotten this to work - has anyone else had trouble?
0
Steve
Telerik team
answered on 17 Mar 2009, 08:09 AM
Hi TMPA,

Where and how do you load the external stylesheet? If you are doing it from the calling application, you should be using code like this:

ExternalStyleSheet ess = new ExternalStyleSheet("sampleStyle.xml");
Telerik.Reporting.Report report = (Telerik.Reporting.Report)this.reportViewer1.Report;
report.ExternalStyleSheets.Add(ess);


Regards,
Steve
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
rajesh kumar
Top achievements
Rank 1
answered on 14 Dec 2009, 11:19 AM
hi

I have the same issue with my project which rh expalined....

We have styles defined in an external stylesheet that look fine in the designer and in the preview but when added to an ASP.NET website project the report renders, the images included as resources also render fine but the external stylesheet is not applied - oddly the background images show up but none of the font stylings are applied. I have followed the instructions carefully but have never successfully gotten this to work - has anyone else had trouble?


I have the style sheet inside the report library project and i am displaying the reports using my report viewer from my main project.


Please Reply soon.........






0
rajesh kumar
Top achievements
Rank 1
answered on 14 Dec 2009, 11:19 AM
please help me.........
0
Nancy
Top achievements
Rank 1
answered on 08 Dec 2016, 10:35 PM

I am new to using Telerik Report Viewer and reports. 

Used an external style sheet on all my reports now am ready to deploy. However,   have not found where or how to publish the external style sheet. 

If this is not the correct place to ask this question, please forward this message to the proper person or site.

 

Thanks.

0
Katia
Telerik team
answered on 12 Dec 2016, 03:47 PM
Hello Nancy,

While designing the report you can add an external stylesheet through the report's ExternalStyleSheets collection by specifying path or by resource name - External Style Sheet Location Kinds.

Then, on deploying the project external stylesheet will be searched by the specified URI.


Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
rh
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
MiroslavStantic
Top achievements
Rank 1
rh
Top achievements
Rank 1
AgJeff
Top achievements
Rank 1
Steve
Telerik team
rajesh kumar
Top achievements
Rank 1
Nancy
Top achievements
Rank 1
Katia
Telerik team
Share this question
or