{"id":1114,"date":"2009-10-16T00:07:13","date_gmt":"2009-10-16T06:07:13","guid":{"rendered":"http:\/\/bililite.nfshost.com\/blog\/?p=1114"},"modified":"2009-10-16T00:33:56","modified_gmt":"2009-10-16T06:33:56","slug":"column-widths-in-ooo-tables","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2009\/10\/16\/column-widths-in-ooo-tables\/","title":{"rendered":"Column Widths in OOo Tables"},"content":{"rendered":"<p>Finding the width of a column in a table in OpenOffice.org writer is a bit of a black art, because the widths aren't stored anywhere, just the relative widths in arbitrary units. And if cells have been combined, then <a href=\"http:\/\/wiki.services.openoffice.org\/wiki\/Documentation\/DevGuide\/Text\/Tables\">the object model has no concept of \"columns\" and there is no way to find the widths of cells<\/a>. But, based on the <a href=\"http:\/\/wiki.services.openoffice.org\/wiki\/API\/Samples\/Java\/Writer\/TextTable\">table tutorial<\/a>, I've written this function:<\/p>\r\n<pre><code class=\"language-vb\">function colwidth (table, index) ' index is 0-based\r\n\t' need the table to be oriented (http:\/\/api.openoffice.org\/servlets\/ReadMsg?list=dev&msgNo=12552) \r\n\ttable.horiOrient = com.sun.star.text.HoriOrientation.LEFT_AND_WIDTH\r\n\t' tricks from http:\/\/wiki.services.openoffice.org\/wiki\/API\/Samples\/Java\/Writer\/TextTable\r\n\tdim n\r\n\tn = table.columns.count\r\n\tif index >= n then\r\n\t\tcolwidth = 0\r\n\telseif n = 1 then ' single column table\r\n\t\tcolwidth = table.width\r\n\telse\r\n\t\tdim ratio as double\r\n\t\tratio = table.width \/ table.tableColumnRelativeSum\r\n\t\tdim pos\r\n\t\tpos = table.tableColumnSeparators\r\n\t\tif index = 0 then\r\n\t\t\tcolwidth = pos(0).position * ratio\r\n\t\telseif index = n-1 then ' last column\r\n\t\t\tcolwidth = (table.tableColumnRelativeSum - pos (ubound(pos)).position) * ratio\r\n\t\telse\r\n\t\t\tcolwidth = (pos(index).position - pos(index-1).position) * ratio\r\n\t\tend if\r\n\tend if\r\nend function<\/code><\/pre>","protected":false},"excerpt":{"rendered":"Finding the width of a column in a table in OpenOffice.org writer is a bit of a black art, because the widths aren't stored anywhere, just the relative widths in arbitrary units. And if cells have been combined, then the object model has no concept of \"columns\" and there is no way to find the [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1114"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=1114"}],"version-history":[{"count":2,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1114\/revisions"}],"predecessor-version":[{"id":1116,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/1114\/revisions\/1116"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=1114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=1114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=1114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}