Azzera filtri
Azzera filtri

Table cell formating is overwritten when inserting text with Matlab Report Generator

6 visualizzazioni (ultimi 30 giorni)
Hi,
I have the following problem. I have a Word template, which I want to fill out with Matlab Report Generator. I got basic text insertion working with the dom api (moveToNextHole) and the reporter api (customizeReport and fill). However, both methods yield the same problem.
My template is kind of a form, where the layout is created with an invisible table (table with no border). I placed "Holes" inside the corresponding table cells where my data should go. But if I insert the text via the api, the corresponding cells alwalys get a solid black border in the output file. I could not find any hint in the documentation regarding tables in the template, only how to programmatically create tables from scratch with the api. Do you have any advice how to fix this issue?
Regards

Risposte (1)

Githin George
Githin George il 9 Ott 2023
Hi Dominik,
I understand you are able to obtain data to be placed in the generated report but unable to configure the styling as required.
I’ve found a way by which I can use just one hole in the word template to create a table, provided the data for the table is available. The default styling is an invisible table with ‘no border’ as you expect. Please see the code given below
import mlreportgen.dom.*;
doc = Document('Report', 'docx', 'YourTemplate');
% Moving to the hole that should contain the data
holeId = moveToNextHole(doc);
% Example Data
tableData = cell2table({"cell11" "cell12"; "cell21" "cell 22"})
% Generating Table into the report
tObj = Table(tableData);
append(doc,tObj);
You can also refer to the documentation to see more styling properties for Table function: https://www.mathworks.com/help/rptgen/ug/mlreportgen.dom.table-class.html?s_tid=doc_ta
The following technical article also provides working example for the same.
I hope it helps.

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by