简体   繁体   English

以编程方式使用外部CSS

[英]Using external CSS programmatically

I want to use an external css when executing the BIRT report via a Java application. 通过Java应用程序执行BIRT报告时,我想使用外部CSS。 I've come along with a few articles which sets the css at runtime over 我附带了一些文章,这些文章在运行时设置了CSS

design.getDesignHandle().addCss("someCss.css");

but it seems that it's deprecated. 但似乎已弃用。 I'm using BIRT 4.4.2. 我正在使用BIRT 4.4.2。 Any suggestions how I could set a css file at runtime? 关于如何在运行时设置css文件的任何建议?

I've done it. 我做完了

First of all you have to make sure to USE the css file and not to import it. 首先,您必须确保使用css文件,而不要导入它。 After that you could set the css properties via the Property Editor. 之后,您可以通过属性编辑器设置css属性。 The external CSS must have the same structure as the file you have declared before. 外部CSS必须具有与之前声明的文件相同的结构。 After that you can use the external CSS with the code below: 之后,您可以将外部CSS与以下代码一起使用:

ReportDesignHandle report = (ReportDesignHandle)design.getDesignHandle();
report.addCss(report.openCssStyleSheet("pathToCSS/someCss.css"));
design.setDesignHandle(report);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM