After all the table style ... () functions have been applied on cells, rows, columns and/or the entire table, one additional step
is necessary before saving the tables, namely translating the generic formatting applied to target-specific formatting, i.e. HTML markups for
HTML files, and Excel formatting markups for the Excel (XML 2003) file format.
The following functions are available:
table load( t, "Examples\Cities.csv" );
// Freeze panes and apply an autofilter
table style table( t, sheet, freeze rows, 1, freeze columns, 2, autofilter, 0 );
for all parameters( { 10, 20, 20, 14, 20, 10, 20, 20 }, width[], col[] )
{
table style columns( t, col[], sheet, column width, width[] );
}
table style rows( t, 0, table, row height, 32, vertical align, center,
fill color, gray 14, boldface, true, font size, 12, wrap text, true );
table style columns( t, { City, Country }, body, text color, blue, boldface, true, italic, true );
table process selected rows( t, [Inhabitants]>=1000000,
table style cells( t, Inhabitants, row(), single,
text color, royal purple, fill color, champagne, boldface, true ) );
border[] = { medium, red };
table process selected rows( t, ([Famous cultural place]=+'*theater*','*opera*'),
table style cells( t, { City, Famous cultural place}, row(), matrix,
text color, mandarin, fill color, lemon, boldface, true,
left border, border[], right border, border[], top border, border[], bottom border, border[] ) );
// Number format is supported in Excel only
table style columns( t, {Inhabitants,"Alt. (m)"},body, horizontal align, right, number format, "#,##0" );
table save( t, "Images/Style_Function_table_style_professionally.xls", EXCEL );
table save excel file( t, Contents, "Images/Style_Function_table_style_professionally.xlsx" );
// How to apply number formats in HTML for browsers
table process ( t, [Inhabitants] = str([Inhabitants], '#,##0', local) );
table process selected rows( t, ['Alt. (m)'] != '', ['Alt. (m)'] = str(['Alt. (m)'] , '#,##0', local) );
table style columns( t, {Inhabitants,"Alt. (m)"},body, type, string );
table save( t, "Images/Style_Function_table_style_professionally.html", HTML );
file copy overwrite( "Images/Style_Function_table_style_professionally.html", "Images/Style_Function_table_style_professionally_in_html.xls" );
echo("Done.");
Saved table(s) to EXCEL file 'Images/Style_Function_table_style_professionally.xlsx' containing 1 sheets.
Done.
Test Click on the file name view the result: Style_Function_table_style_professionally.html.
Test Click on the file name open the file with Excel: Style_Function_table_style_professionally.xls (Excel XML 2003 format - confirm the message box query).
Test Click on the file name open the HTML file with Excel: Style_Function_table_style_professionally_in_html.xls (Note: HTML file opened with Excel).
Test Click on the file name open the file with Excel (.xlsx) : Style_Function_table_style_professionally_in_html.xlsx (Excel .xlsx format).