分三种方法:
[color=red][b]第三种是自己设定出来的[/b].[/color]
[b]第一种:[/b]
今天看见了安迅描述BIRT2.5字体换行的设置那篇文章中,,,我照着设置了下,还把文字设置居中和垂直设置居中,然后没注意看,,报表居然居中显示了。这是很不起眼的设置,解决了一点报表显示的问题,以后我们的报表不用靠边显示了,,
首先,,选择你的报表右键,,我的是table,,我就以table为例,在table单击右键如图
把vertical aliagnment 和 Text alignment 都为居中,设置whitespace 为no wrraping 是文字换行的,挺实用的东东,这样预览你的报表是不是居中显示了。。无意中测试出来的
[b]第二种:[/b]
Birt报表默认的是靠左对齐的,显示和打印都不够美观,那么怎么才能居中对齐呢?
前提:报表模板用 布局Auto Layout,并且需要显示指定每列的宽度或整个模板的宽度。对于交叉表,一般是显示指定每列的宽度。
一、显示居中
修改webcontent/birt/styles/style.css文件,在BirtViewer_Body样式中增加text-align:center;即可
二、打印居中
1、将org/eclipse/birt/report/engine/emitter/html中的源码复制到你的工程中
2、修改org/eclipse/birt/report/engine/emitter/html/HTMLReportEmitter.java文件
2.1 将1477行附近的
else if ( !fixedReport )
{
styleBuffer.append( " width:100%;" );
}
改成
else if ( !fixedReport )
{
styleBuffer.append( " width:100%;text-align:center;" );
}
2.2 将850行附近的
else
{
//The document type must be output before open the "html" tag.
writer.outputDoctype( );
writer.openTag( HTMLTags.TAG_HTML );
}
改成
else
{
//The document type must be output before open the "html" tag.
//writer.outputDoctype( );
writer.openTag( HTMLTags.TAG_HTML );
}
此方案在IE浏览器中测试通过。
[color=red][b]第三种:css方式[/b][/color]
先使用一个grid空间来布局
然后设定grid的宽度
最后设定grid的属性:
top:0px, bottom:0px, left:auto, right:auto