The simplest way to create a table would be with either HTML or RTF. HTML is easier, but RTF looks like a normal description table, while the HTML version looks a bit different.
Prerequisites
- Familiar with the Coding guidelines regarding editing Description.
HTML Table
RTF Table
HTML Table Code Example
SWConnection.Instance.LoginName = "admin"; SWConnection.Instance.Password = "password"; SWConnection.Instance.ServerMachineName = "servername"; SWConnection.Instance.ServerPort = 1337; SWConnection.Instance.Login(); var broker = SWConnection.Instance.Broker; IswItem item = broker.GetItem(SWHandleUtility.ToHandle("x0400000000020E6E")); var htmlTable = @" <table> <tr> <th>Header 1</th> <th>Header 2</th> <th>Header 3</th> </tr> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> </tr> <tr> <td>Cell 4</td> <td>Cell 5</td> <td>Cell 6</td> </tr> </table> "; var tempFilePath = System.IO.Path.GetTempFileName(); System.IO.File.WriteAllText(tempFilePath, htmlTable); item.Description = SWDescription.MakeDescription(SWUtility.HtmlToRvfz(tempFilePath, "Arial"));
RTF Table Code Example
(RTF was originally retrieved by using SWDescription.DescriptionToRtf on a description containing a table with the wanted format)
SWConnection.Instance.LoginName = "admin"; SWConnection.Instance.Password = "password"; SWConnection.Instance.ServerMachineName = "servername"; SWConnection.Instance.ServerPort = 1337; SWConnection.Instance.Login(); var broker = SWConnection.Instance.Broker; IswItem item = broker.GetItem(SWHandleUtility.ToHandle("x0400000000020E6E")); var rtfTable = @"{\rtf1\fbidis\ansi\ansicpg0\uc1\deff0\deflang0\deflangfe0{\fonttbl{\f0\fnil Arial;}}{\colortbl;\red255\green255\blue255;} \pard\fi0\li0\ql\ri0\sb0\sa0\itap0 {\pard\intbl\trowd\trgaph22\trleft0\trpaddl15\trpaddt15\trpaddr15\trpaddb15\trpaddfl3\trpaddft3\trpaddfr3\trpaddfb3\trwWidth5000\trftsWidth2\richviewtbwtw-100\trcbpat1\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx330\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx675\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx1020{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\b\fs24 Header 1\cell}{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\b\fs24 Header 2\cell}{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\b\fs24 Header 3\cell}\trowd\trgaph22\trleft0\trpaddl15\trpaddt15\trpaddr15\trpaddb15\trpaddfl3\trpaddft3\trpaddfr3\trpaddfb3\trwWidth5000\trftsWidth2\richviewtbwtw-100\trcbpat1\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx330\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx675\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx1020\row}{\pard\intbl\trowd\trgaph22\trleft0\trpaddl15\trpaddt15\trpaddr15\trpaddb15\trpaddfl3\trpaddft3\trpaddfr3\trpaddfb3\trwWidth5000\trftsWidth2\richviewtbwtw-100\trcbpat1\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx330\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx675\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx1020{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\fs24 Cell 1\cell}{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\fs24 Cell 2\cell}{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\fs24 Cell 3\cell}\trowd\trgaph22\trleft0\trpaddl15\trpaddt15\trpaddr15\trpaddb15\trpaddfl3\trpaddft3\trpaddfr3\trpaddfb3\trwWidth5000\trftsWidth2\richviewtbwtw-100\trcbpat1\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx330\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx675\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx1020\row}{\pard\intbl\trowd\trgaph22\trleft0\trpaddl15\trpaddt15\trpaddr15\trpaddb15\trpaddfl3\trpaddft3\trpaddfr3\trpaddfb3\trwWidth5000\trftsWidth2\lastrow\richviewtbwtw-100\trcbpat1\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx330\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx675\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx1020{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\fs24 Cell 4\cell}{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\fs24 Cell 5\cell}{ \pard\fi0\li0\ql\ri0\sb0\sa0\intbl \plain \f0\fs24 Cell 6\cell}\trowd\trgaph22\trleft0\trpaddl15\trpaddt15\trpaddr15\trpaddb15\trpaddfl3\trpaddft3\trpaddfr3\trpaddfb3\trwWidth5000\trftsWidth2\lastrow\richviewtbwtw-100\trcbpat1\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx330\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx675\clftsWidth1\richviewcbwtw0\richviewcbhtw0\clbrdrl\brdrs\brdrw15\brdrcf0\clbrdrt\brdrs\brdrw15\brdrcf0\clbrdrr\brdrs\brdrw15\brdrcf0\clbrdrb\brdrs\brdrw15\brdrcf0\cellx1020\row}\par}"; item.Description = SWDescription.RtfToDescription(rtfTable);