ReportGen HeaderRow.Style does not seem to translate to word document?

3 ビュー (過去 30 日間)
Hi - I'm tyring to format a table using code for a word template. I am trying to place a border above and below the header row (first row with the column headers) and (evntually) a border below the last line. I have tried to create a headerRowStyle (generic), then modify as such:
% Generic header row with buffer margins and borders
headerRowStyle = ...
{ ...
InnerMargin("2pt","2pt","2pt","2pt"), ...
Bold(true), RowSep('solid'), ...
Border('solid'),...
};
% Remove the border on left and right, keep top and bottom
HeaderRow = AT.Header.Children;
headerRowStyle{1,4}.LeftStyle = [];
headerRowStyle{1,4}.RightStyle = [];
headerRowStyle{1,4}.BottomStyle = 'solid';
headerRowStyle{1,4}.BottomColor = 'black';
headerRowStyle{1,4}.BottomWidth = '48px';
% Set the style
HeaderRow.Style = headerRowStyle;
My table is a FormalTable (called AT).
This puts a border on top, but not really on the bottom (it's very faint - that's why I tried '48px' figuring it was be insanely thick). According to the headerRowStyle, it should be as I wish:
I can change the width to any size and there is no change... Maybe I'm going about this all wrong, but I want a table like this:
What I get (no matter what I change border with to) is this:
I have to be doing something wrong obviously... Anyone konw what??? Thanks!

採用された回答

Harikrishnan Balachandran Nair
Harikrishnan Balachandran Nair 2022 年 1 月 27 日
編集済み: Harikrishnan Balachandran Nair 2022 年 1 月 27 日
H Thomas,
I understand that you are trying to format a table before appending it to the doc , such that it has a border line at the top and bottom , and a seperation between the header and body.
One possible way would be to set the header style as needed, and then remove the left and right border from the whole table.
You may refer to the following code for the same :
import mlreportgen.dom.*
% Create a document
d = Document('outputtest', 'docx');
open(d);
% Create a FormalTable with one header row and two body rows
AT = FormalTable({'Col1', 'Col2', 'Col3'}, {'entry11', 'entry12','entry13'; 'entry21', 'entry22','entry23'});
headerRowStyle = ...
{ ...
InnerMargin("2pt","2pt","2pt","2pt"), ...
Bold(true), RowSep('solid'), ...
Border('solid'),...
};
HeaderRow = AT.Header;
% Set the style
HeaderRow.Style = headerRowStyle;
AT.Style = {Border('single')};
AT.Style{1,1}.LeftStyle = 'none';
AT.Style{1,1}.RightStyle = 'none';
AT.Header.RowSepWidth = '48px';
append(d,AT);
% Close and view report
close(d);
rptview(d);
Please refer to the following Documentations to learn more on this :
  1 件のコメント
Thomas Boyd
Thomas Boyd 2022 年 1 月 28 日
Thanks... Haven't drilled down into the properties yet, but plugging this code in did the trick...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by