OpenDocument4all - Info and tools about OpenDocument
Sunday, 05 February 2012
Home arrow Forum
Forum Statistics
Total user: 89
Total message: 179
Main Menu
Home
My Blog
AODL - Project
AODC - Project
OO Development & Info
Forum
About OpenDocument ...
Search
News
Contact Us
Login Form





Lost Password?
No account yet? Register
Sourceforge.net

SourceForge.net - Goto the project homepage
Project site on SF.net

 

Demand OpenDocument

 

Countomat Webcounter und Webstatistik (Statistik & Logfileanalyse, Counter)

OpenDocument4all-Forum

 
How to: Text Document Table Width
Date: 2007/07/27 05:19 By: Brad Campbell Status: User  
Karma: 0  
Junior Boarder

Posts: 9
graphgraph
The TableStyle.TableProperties class is missing a bit of functionality that allows you to actually set the width of a table in a text document. I brewed up some code to overcome this. In the following example the table is created so that it's edges are 1.2 inches in from the margins.

//Create a new table style
AODL.Document.Styles.TableStyle ts = new AODL.Document.Styles.TableStyle(doc,"TableBLC");
ts.TableProperties.Width = "3.6in"; //This doesn't really set the width at all
ts.TableProperties.Align = "margins";

//We can only really add attributes to XmlElements, so cast the TableProperties Node (an xmlnode)
//to an XmlElement that we can play with

System.Xml.XmlElement tsel = (System.Xml.XmlElement)ts.TableProperties.Node;

//Set the margin-left and margin-right attributes
//They are in the ":fo" namespace - remove the _ from _xmlns - it's there to keep a smiley from being there

tsel.SetAttribute("margin-left","urn:oasis:names:tc:opendocument:_xmlns:fo:1.0", "1.2in");
tsel.SetAttribute("margin-right","urn:oasis:names:tc:opendocument:_xmlns:fo:1.0", "1.2in");

//Cast our XmlElement back an XmlNode and reassign to the TableProperties node
ts.TableProperties.Node = (System.Xml.XmlNode)tsel;
//Add our style to the document
doc.Styles.Add(ts);

//Later on you apply the table style when you create the table
Table table = TableBuilder.CreateTextDocumentTable(doc, "table1", "TableBLC", lines.Length - 1, cellText.Length, 1.0, false, true);
//or after the table is created
table.TableStyle.StyleName = "TableBLC";

To adjust the width of columns within a table I believe the property to play with is the RelativeWidth property in ColumnStyle.ColumnProperties. If one column has a RelativeWidth of "2*" and another has a RelativeWidth of "1*" then the first one is twice as wide as the other.

That's all for now. Figuring this stuff out hurts my head.

Brad
The administrator has disabled public write access.

Re:How to: Text Document Table Width
Date: 2007/07/27 05:26 By: Brad Campbell Status: User  
Karma: 0  
Junior Boarder

Posts: 9
graphgraph
The attribute section should actually be:

tsel.SetAttribute("margin-left", "urn:oasis:names:tc:opendocumentmlns:fo:1.0", "1.2in");
tsel.Attributes[tsel.Attributes.Count - 1].Prefix = "fo";
tsel.SetAttribute("margin-right", "urn:oasis:names:tc:opendocumentmlns:fo:1.0", "1.2in");
tsel.Attributes[tsel.Attributes.Count - 1].Prefix = "fo";
The administrator has disabled public write access.

Quick jump
Download area
Who's Online
We have 31 guests online
Polls
Should AODL and AODC also implement export as PDF and RTF?
 
Popular
© 2005 MamboZ. All rights reserved.