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.