In the latest version of the HTML TreeGrid we have added support for customs style sheets. this allows us to control the appearance of the HTML output. The word output is actually just an HTML version of the exporter. Microsoft Word is able to open up and render HTML just fine which is what we use for our word exports. Just a quick note we use the same concept for Excel exports and as demonstrated in this blog post http://blog.htmltreegrid.com/post/How-to-Generate-Excel-XLS-files-and-avoid-the-Excel-scientific-notation-for-numbers.aspx
As with anything else in our software we ship with the default style sheet for the word and the HTML export. The default version of the style sheet is below
Constants.HTML_EXPORT_CSS= "<style>"+
"table {font-family: Arial, Verdana, sans-serif;border-collapse: collapse; border-spacing: 0; } "+
"td {border: 1px solid #CCC; text-align: center;width: 10em;padding: 1em;} "+
"th {border: 1px solid #CCC; text-align: center;padding: 1em;background-color: #DFDFDF;}"+
"tr {height: 1em;}"+
"table tr.even {background-color: #F1F1F1;}"+
"table tr.footer {border: 1px solid #CCC; text-align: center;padding: 1em;background-color: #DFDFDF;}"+
"table tr.odd {background-color:#fefefe;}</style>";
Constants.WORD_EXPORT_CSS= "<style>"+
"table {font-family: Arial, Verdana, sans-serif;border-collapse: collapse; border-spacing: 0; } "+
"td {border: 1px solid #CCC; text-align: center;width: 10em;padding: 1em;} "+
"th {border: 1px solid #CCC; text-align: center;padding: 1em;background-color: #DFDFDF;}"+
"tr {height: 1em;}"+
"table tr.even {background-color: #F1F1F1;}"+
"table tr.footer {border: 1px solid #CCC; text-align: center;padding: 1em;background-color: #DFDFDF;}"+
"table tr.odd {background-color:#fefefe;}</style>";
As always you can customize this by overwriting these variables. this is what we going to do in this example.
please download the example below and running locally to see the impact.
CustomExportStyles.html (4.54 kb)