How to adjust width and height of table and other table properties in Microsoft word document from MATLAB code and addition of picture in table?
조회 수: 8 (최근 30일)
이전 댓글 표시
I have created Microdsoft word document using " c =actxword('Word.Application') " statement.In the document I have succesfully created table of 3X3 and 1st column is merged.
1.) Now I want to adjust the width of 1st and 3rd column and rows also.
2.) In first Column I want to add picture.
---------------------------------------------------------------------------------
c =actxserver('Word.Application')
c.Visible =1;
document=c.Documents.Add;
selection=c.Selection;
word.ActiveDocument.Tables.Add(word.Selection.Range,3,3);
tableObj = word.ActiveDocument.Tables.Item(1);
tableObj.Borders.Enable = 1; %create borders of table
handles.selection.MoveDown(5,3,1) %selection of first column
handles.selection.Cells.Merge() %Merge selected cells
handles.selection.MoveRight() % Move cursor to right
handles.selection.MoveRight(1,2,1) %selection of cells of 1st row and 2nd & 3rd column
handles.selection.Cells.Merge() %Merge selected cells
word.Selection.TypeText('text'); %Type text
handles.selection.MoveDown() % Move cursor downward
word.Selection.TypeText('text'); % type text
handles.selection.MoveRight() % Move cursor to right
word.Selection.TypeText('text'); % type text
handles.selection.MoveDown() % Move cursor downward
handles.selection.MoveLeftt(1,2,1) %Selection
handles.selction.Cells.Merge() %Merge sected celss
word.Selection.TypeText('text'); % type text
--------------------------------------------------
Any idea to generate desired output is highly appreciated.

댓글 수: 0
답변 (1개)
Wenquan
2023년 2월 14일
Hi,you can try creating a matrix first and set the row height and column width by looping.
% Set row height, column width
column_width = [...];
row_height = [...];
for i = 1:3
DTI.Columns.Item(i).Width = column_width(i);
end
for i = 1:3
DTI.Rows.Item(i).Height = row_height(i);
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!