W3C home > Mailing lists > Public > www-xsl-fo@w3.org > May 2008

Re: more advanced table column aligning

From: jlr <jean.stachler@crown.com>
Date: Sun, 4 May 2008 09:39:01 -0700 (PDT)
Message-ID: <17048524.post@talk.nabble.com>
To: www-xsl-fo@w3.org


Below is some code that I am currently using in a table for one of my
projects.

I am using the attribute-set titled "detailtablecenter" when I want the data
centered in the table.
For the data that I want set to the right, I use the "detailtableright"
attribute-set.
In the first block, this is showing the table headers which are centered. 
In the second block,
this is showing the data which is appropriately centered for the columns
that are not holding
dollar amounts.  
Hope this helps.
jlr

 <xsl:attribute-set name="detailtablecenter">
            <xsl:attribute name="font-size">8pt</xsl:attribute>
            <xsl:attribute name="start-indent">.0in</xsl:attribute>
           <xsl:attribute name="end-indent">0.0in</xsl:attribute>
           <xsl:attribute name="space-after">0</xsl:attribute>
           <xsl:attribute name="space-after.maximum">1em</xsl:attribute> 
           <xsl:attribute name="text-align">center</xsl:attribute>    
           <xsl:attribute name="padding-before">0.5pt</xsl:attribute>
           <xsl:attribute name="padding-after">0.5pt</xsl:attribute>
           <xsl:attribute name="padding-start">0.5pt</xsl:attribute>
           <xsl:attribute name="padding-end">0.5pt</xsl:attribute>          
    </xsl:attribute-set>


       <xsl:attribute-set name="detailtableright">
            <xsl:attribute name="font-size">8pt</xsl:attribute>
            <xsl:attribute name="start-indent">.0in</xsl:attribute>
           <xsl:attribute name="end-indent">0.0in</xsl:attribute>
           <xsl:attribute name="space-after">0</xsl:attribute>
           <xsl:attribute name="space-after.maximum">1em</xsl:attribute> 
            <xsl:attribute name="text-align">right</xsl:attribute> 
            <xsl:attribute name="padding-before">0.5pt</xsl:attribute>
           <xsl:attribute name="padding-after">0.5pt</xsl:attribute>
           <xsl:attribute name="padding-start">0.5pt</xsl:attribute>
           <xsl:attribute name="padding-end">0.5pt</xsl:attribute>          
    </xsl:attribute-set>
<fo:block  text-align="left" >        
          <fo:table table-layout="fixed" >                                           
          <fo:table-column column-width="20mm"/>
          <fo:table-column column-width="24mm"/>
          <fo:table-column column-width="14mm"/>
           
             <fo:table-body>
                <fo:table-row border-after-style="double" >                   
                                 <fo:table-cell
xsl:use-attribute-sets="cell-padding-all" border="solid black 0.5px"
background-color="rgb(232,233,207)" >       
                     <fo:block xsl:use-attribute-sets="detailtablecenter">         
                         <xsl:value-of select="header/Column6Title"/>
                     </fo:block>                                   
                 </fo:table-cell>                 
                 <fo:table-cell  xsl:use-attribute-sets="cell-padding-all" 
border="solid black 0.5px" background-color="rgb(232,233,207)" >                                                              
                     <fo:block xsl:use-attribute-sets="detailtablecenter">   
                          <xsl:value-of select="header/Column7Title"/>                        
                     </fo:block>   
                 </fo:table-cell>
                 <fo:table-cell xsl:use-attribute-sets="cell-padding-all"
border="solid black 0.5px" background-color="rgb(232,233,207)" >        
                     <fo:block xsl:use-attribute-sets="detailtablecenter">    
                          <xsl:value-of select="header/Column8Title"/>                      
                     </fo:block>                                   
                 </fo:table-cell>                           
             </fo:table-row>         
                                                       
            </fo:table-body>
          </fo:table>
        </fo:block>       

         <fo:block  text-align="left">
          <fo:table table-layout="fixed" >                                           
          <fo:table-column column-width="20mm"/>
          <fo:table-column column-width="24mm"/>
          <fo:table-column column-width="14mm"/>
           
          <fo:table-body> 
              <xsl:for-each select="header/row">        
                  <fo:table-row border-after-style="double" >                   
                     <fo:table-cell xsl:use-attribute-sets="numeric-cell"
border="solid black 0.5px" >   
                      <xsl:variable name="q">
                            <xsl:value-of select="column6"/>
                      </xsl:variable>
                      <fo:block xsl:use-attribute-sets="detailtableright">   
                         <xsl:value-of
select="format-number($q,'$###,###,###.0000')"/>                           
                     </fo:block>                                   
                 </fo:table-cell>                 
                 <fo:table-cell  xsl:use-attribute-sets="numeric-cell" 
border="solid black 0.5px" >       
                 <xsl:variable name="q">
                     <xsl:value-of select="column7"/>    
                 </xsl:variable>                                               
                 <fo:block xsl:use-attribute-sets="detailtableright">   
                    <xsl:value-of
select="format-number($q,'$###,###,###.00')"/>                               
                 </fo:block>   
                 </fo:table-cell>
                 <fo:table-cell xsl:use-attribute-sets="cell-padding"
border="solid black 0.5px" >   
                     <fo:block xsl:use-attribute-sets="detailtablecenter">    
                          <xsl:value-of select="column8"/>                      
                     </fo:block>                                   
                </fo:table-cell>                           
             </fo:table-row>       

Arian Hojat wrote:
> 
> 
> i was requested to change my columns of a table i made from center
> aligned to flush right since the table cells were numbers like $10.00
> and needed to be aligned.
> and I did that. but then the clients wanted the header row columns
> centered over those flush right columns. kinda got stumped. i thought
> easiest way would be to leave all the table cells  (header and data
> rows) flush right but apply negative margins to the right side of the
> header row's cells (so slightly moving those columns to the right).
> That didnt seem to work (negative margins werent respected in newest
> FOP). Then I changed the header columns back to center align but left
> the data columns at flush right, and applied regular right margins to
> each data cell. So basically moved the columns to look like they are
> centered. This was alot more work.
> Is there a better way to do this?
> 
> Thanks,
> Arian
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/more-advanced-table-column-aligning-tp17047648p17048524.html
Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com.
Received on Sunday, 4 May 2008 16:39:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 4 May 2008 16:39:38 GMT