sprintf text justification in uitable

1 回表示 (過去 30 日間)
Jared
Jared 2013 年 2 月 28 日
I set the text in each cell of a uitable with sprintf so I can specify the number format of the data I am displaying. Is there any way to make these numbers centered in the table cells?

採用された回答

Walter Roberson
Walter Roberson 2013 年 2 月 28 日
Not exactly. You can set the font to a fixed width font, and set the ColumnFormat to 'char', and you can set the ColumnWidth to particular number of pixels. But then you need to set the cell contents to a character string calculated to center in that width.
cb = (col_pixel_width / pixels_per_char - chars_needed_for_value) / 2;
formatted_field = [blanks(floor(cb)) unformated_field blanks(ceil(cb))];

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by