Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How to center table in generated html file and auto wrap text in table cell(How to center table in generated html file and auto wrap text in table cell)
How to center table in generated html file and auto wrap text in table cell [message #1828954] Tue, 23 June 2020 07:31 Go to next message
丁 涛 is currently offline 丁 涛Friend
Messages: 1
Registered: June 2020
Junior Member
Hello everyone!

I need to center table in generated html and auto warp text in table cell.

Here is my rptdesign file:
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
    <property name="createdBy">Eclipse BIRT Designer Version 4.6.0.v201606072122</property>
    <property name="units">in</property>
    <property name="iconFile">/templates/blank_report.gif</property>
    <property name="imageDPI">120</property>
    <data-sources>
        <script-data-source name="Data Source" id="4"/>
    </data-sources>
    <data-sets>
        <script-data-set name="Data Set" id="5">
            <list-property name="resultSetHints">
                <structure>
                    <property name="position">0</property>
                    <property name="name">name</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">1</property>
                    <property name="name">age</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">2</property>
                    <property name="name">location</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">3</property>
                    <property name="name">email</property>
                    <property name="dataType">string</property>
                </structure>
            </list-property>
            <list-property name="columnHints">
                <structure>
                    <property name="columnName">name</property>
                    <text-property name="displayName">name</text-property>
                </structure>
                <structure>
                    <property name="columnName">age</property>
                    <text-property name="displayName">age</text-property>
                </structure>
                <structure>
                    <property name="columnName">location</property>
                    <text-property name="displayName">location</text-property>
                </structure>
                <structure>
                    <property name="columnName">email</property>
                    <text-property name="displayName">email</text-property>
                </structure>
            </list-property>
            <structure name="cachedMetaData">
                <list-property name="resultSet">
                    <structure>
                        <property name="position">1</property>
                        <property name="name">name</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">2</property>
                        <property name="name">age</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">3</property>
                        <property name="name">location</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">4</property>
                        <property name="name">email</property>
                        <property name="dataType">string</property>
                    </structure>
                </list-property>
            </structure>
            <property name="dataSource">Data Source</property>
            <method name="open"><![CDATA[count = 0;]]></method>
            <method name="fetch"><![CDATA[if(count<2){
	row["name"] = "namenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamenamename";
	row["age"] = "ageageageageageageageageageageageageageageageageageageageageageageageageageageageageageageage";
	row["location"] = "location";
	row["email"] = "email"
	count++;
	return true;
}
return false;]]></method>
            <method name="close"><![CDATA[]]></method>
        </script-data-set>
    </data-sets>
    <styles>
        <style name="NewStyle" id="39">
            <property name="borderBottomStyle">solid</property>
            <property name="borderLeftStyle">solid</property>
            <property name="borderRightStyle">solid</property>
            <property name="borderTopStyle">solid</property>
        </style>
    </styles>
    <body>
        <grid id="6">
            <column id="7"/>
            <row id="8">
                <cell id="9">
                    <table id="10">
                        <property name="width">80%</property>
                        <property name="dataSet">Data Set</property>
                        <list-property name="boundDataColumns">
                            <structure>
                                <property name="name">name</property>
                                <text-property name="displayName">name</text-property>
                                <expression name="expression" type="javascript">dataSetRow["name"]</expression>
                                <property name="dataType">string</property>
                            </structure>
                            <structure>
                                <property name="name">age</property>
                                <text-property name="displayName">age</text-property>
                                <expression name="expression" type="javascript">dataSetRow["age"]</expression>
                                <property name="dataType">string</property>
                            </structure>
                            <structure>
                                <property name="name">location</property>
                                <text-property name="displayName">location</text-property>
                                <expression name="expression" type="javascript">dataSetRow["location"]</expression>
                                <property name="dataType">string</property>
                            </structure>
                            <structure>
                                <property name="name">email</property>
                                <text-property name="displayName">email</text-property>
                                <expression name="expression" type="javascript">dataSetRow["email"]</expression>
                                <property name="dataType">string</property>
                            </structure>
                        </list-property>
                        <column id="34"/>
                        <column id="35"/>
                        <column id="36"/>
                        <column id="37"/>
                        <header>
                            <row id="11">
                                <cell id="12">
                                    <property name="style">NewStyle</property>
                                    <label id="13">
                                        <text-property name="text">name</text-property>
                                    </label>
                                </cell>
                                <cell id="14">
                                    <property name="style">NewStyle</property>
                                    <label id="15">
                                        <text-property name="text">age</text-property>
                                    </label>
                                </cell>
                                <cell id="16">
                                    <property name="style">NewStyle</property>
                                    <label id="17">
                                        <text-property name="text">location</text-property>
                                    </label>
                                </cell>
                                <cell id="18">
                                    <property name="style">NewStyle</property>
                                    <label id="19">
                                        <text-property name="text">email</text-property>
                                    </label>
                                </cell>
                            </row>
                        </header>
                        <detail>
                            <row id="20">
                                <cell id="21">
                                    <property name="style">NewStyle</property>
                                    <data id="22">
                                        <property name="resultSetColumn">name</property>
                                    </data>
                                </cell>
                                <cell id="23">
                                    <property name="style">NewStyle</property>
                                    <data id="24">
                                        <property name="resultSetColumn">age</property>
                                    </data>
                                </cell>
                                <cell id="25">
                                    <property name="style">NewStyle</property>
                                    <data id="26">
                                        <property name="resultSetColumn">location</property>
                                    </data>
                                </cell>
                                <cell id="27">
                                    <property name="style">NewStyle</property>
                                    <data id="28">
                                        <property name="resultSetColumn">email</property>
                                    </data>
                                </cell>
                            </row>
                        </detail>
                        <footer>
                            <row id="29">
                                <cell id="30">
                                    <property name="style">NewStyle</property>
                                </cell>
                                <cell id="31">
                                    <property name="style">NewStyle</property>
                                </cell>
                                <cell id="32">
                                    <property name="style">NewStyle</property>
                                </cell>
                                <cell id="33">
                                    <property name="style">NewStyle</property>
                                </cell>
                            </row>
                        </footer>
                    </table>
                </cell>
            </row>
        </grid>
    </body>
</report>


I am using birt 4.2.2 to generate html file:
        <dependency>
            <groupId>org.eclipse.birt.runtime</groupId>
            <artifactId>org.eclipse.birt.runtime</artifactId>
            <version>4.4.2</version>
        </dependency>


See got.png. It`s what I got.
See want.png. It`s what I want.

Please Help me, thanks!


  • Attachment: got.png
    (Size: 16.37KB, Downloaded 97 times)
  • Attachment: want.png
    (Size: 16.11KB, Downloaded 173 times)
Re: How to center table in generated html file and auto wrap text in table cell [message #1831115 is a reply to message #1828954] Tue, 11 August 2020 21:02 Go to previous message
Thomas Gutmann is currently offline Thomas GutmannFriend
Messages: 21
Registered: April 2020
Junior Member
Hello There,

I have an solution for you.
The idea is to replace the default cell-data elemets with an text-element configured explicit like HTML.
And you can set in the HTML the correct wrapping.

The default wrapping doesn't work.

I have added for you the HTML preview and also a version of your report.
The HTML-text value is e.g.: <div style="word-wrap: break-word"><VALUE-OF>row["name"]</VALUE-OF></div>

Kind regards
Thomas
Previous Topic:Spudsoft XLS Export incorrect height for first row of grouping
Next Topic:Align on Decimal Point for Negative Numbers with Parentheses
Goto Forum:
  


Current Time: Fri Mar 29 15:05:34 GMT 2024

Powered by FUDForum. Page generated in 0.01624 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top