vhandle.tab

vhandle.tab#

Purpose

Class constructor for SDT name tab handle objects.

Description

This is used to generate tabular output of the cell array tt to various supported types : Tab (opens a java tab containing the table), excel (Microsoft Excel only available on windows), html, csv (comma separated values, readable by excel), tex (latex formatting), text printout to the command window.

 % A sample table
 tabdata=num2cell(reshape(1:10,[],2));
 tab=vhandle.tab(tabdata)
 tab.ColumnName={'c1','c2' % Name
  '',''  % cell formating
  '%3i','%.1f'} % Column formating 
 tab.name='TestTab' % tab name in a TabbedPane
 asTab(tab,'SDT Root') % Show as java table in 'SDT Root' figure

tname=nas2up('tempname o.html'); % RO option structure to format a table for HTML or java output RO=struct('fmt',{{'%3i','%.1f'}}, ... % Formatting for each column 'HasHead',1); % a header is provided as strings RO.fopen={tname,'a+'}; % Opening information RO.OpenOnExit=0; RO.Legend=sprintf('<p>%s</p>','My HTML legend'); asHtml(tab,RO) % was comstr(tab,-17,'html',RO); sdtweb('_link',sprintf('web(''%s'')',tname))

% Generate tex output of java tabs comstr(struct('FigTag','SDT Root'),-17,'tex');

Standard table fields are

  • .ColumnName cell array with
    • first row giving column names.
    • .ColumnName(2,:) used to store styling information. For example 'right' for right alignment.
    • .ColumnName(3,:) can also be used to store the column format. These can be strings %.1f,%i,%.2g which are passed to sprintf. They can also be java strings java.lang.String('0.00%') which are then parsed using java.text.DecimalFormat. This was initially given as .fmt cell array of column formatting instructions.
    • .ColumnName(4,:) can also be used to store cell coloring data, see section 7.18.
  • .table matrix or cell array of contents.
  • name is used to define a title for the table. This is the tab name in tabbed pane environments.
  • .setSort activates row sorting in java tables. 1 : basic sort, 2: selectable sort. 3 : groupable tree table, 4 standard SDT tree table handling .level field.

Fields specific for HTML generation are

  • .HasHead if non zero, skips lines of strings
  • .fopen used for HTML generation. For example {tname,'a+'}; is for append. .OpenOnExit asks to open the file in the web browser.

Fields specific for JAVA tabs are

  • .name is used to define a tab name.
  • .FigTag tag or handle for figure where the tab should be displayed.
  • .ColWidth vector of column width in pixels.
  • .groupable used with .setSort=3 to specify columns that will be used to generate the tree.
  • jProp accepts tag,value pairs. 'ResizeMode','Off' to fix columns for example. 'MousePressed',data gives a cell array used to store events that should be handled by the table (see menu_generation('jpropcontext',ua,'Tab.ExportTable')).
  • .ColumnName second row can give alignment . Third row can give column formatting (alternatively, the .RowFmt can be used). Row 4 can be used to define a color based on a CritFcn.