title: Right-align values in UITable in App Designer
body: <p><em>I already asked about this on <a href="https://de.mathworks.com/matlabcentral/answers/324383-uitable-in-app-designer-strips-leading-white-space" rel="nofollow noreferrer">Matlab Answers</a> but did not get a response there, so I try it here.</em></p>
  
  <p>I have some numbers I want to show in a UITable. Since I need a specific formatting of the values (three digits after comma, no scientific notation), I converted the values to strings. The problem is that these strings are by default left-aligned which looks not very nice.</p>
  
  <p>When using UITable in GUIDE, I was able to pad strings with leading spaces to get them right aligned like in the following</p>
  
  <pre><code>data = {'1532.000'; '   5.543'; '  26.457'};
  </code></pre>
  
  <p>Using a mono space font, the values are shown like this in the table:</p>
  
  <pre><code>1532.000
     5.543
    26.457
  </code></pre>
  
  <p>Currently I am considering switching to App Designer. I am using the same space-padded strings but here the uitable seems to strip them off. That is the result looks like the following:</p>
  
  <pre><code>1532.000
  5.543
  26.457
  </code></pre>
  
  <p>Is there a way to make <code>uitable</code> in App Designer keep the spaces like it did in GUIDE?
  Of course it would be even better to directly right-align the strings without the need of padding, but as far as I know this is not possible.</p>
  
  <p>In case it matters: I am using Matlab R2016b.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Minimal example for generating and filling a UITable. This is a simple AppDesigner GUI where I added only a table and a button (without modifying any attributes). The click callback of the button is used to add the data to the table.</p>
  
  <pre><code>classdef test &lt; matlab.apps.AppBase
  
      % Properties that correspond to app components
      properties (Access = public)
          UIFigure  matlab.ui.Figure
          UITable   matlab.ui.control.Table
          Button    matlab.ui.control.Button
      end
  
      methods (Access = private)
  
          % Button pushed function: Button
          function ButtonPushed(app, event)
              data = {'1532.000'; '   5.543'; '  26.457'};
              app.UITable.Data = data;
          end
      end
  
      % App initialization and construction
      methods (Access = private)
  
          % Create UIFigure and components
          function createComponents(app)
  
              % Create UIFigure
              app.UIFigure = uifigure;
              app.UIFigure.Position = [100 100 640 480];
              app.UIFigure.Name = 'UI Figure';
              setAutoResize(app, app.UIFigure, true)
  
              % Create UITable
              app.UITable = uitable(app.UIFigure);
              app.UITable.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'; 'Column 4'};
              app.UITable.RowName = {};
              app.UITable.Position = [127 180 302 185];
  
              % Create Button
              app.Button = uibutton(app.UIFigure, 'push');
              app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);
              app.Button.Position = [220 104 100 22];
          end
      end
  
      methods (Access = public)
  
          % Construct app
          function app = test()
  
              % Create and configure components
              createComponents(app)
  
              % Register the app with App Designer
              registerApp(app, app.UIFigure)
  
              if nargout == 0
                  clear app
              end
          end
  
          % Code that executes before app deletion
          function delete(app)
  
              % Delete UIFigure when app is deleted
              delete(app.UIFigure)
          end
      end
  end
  </code></pre>
  
  <p>After pushing the button the table looks as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/cshDP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cshDP.png" alt="enter image description here"></a></p>
  
  <p>Note that AppDesigner only allows me to modify the code inside the <code>ButtonPushed</code> function.</p>