How do I omit the quotes when writing Cellarray into PDF Report?

조회 수: 35 (최근 30일)
I am using the code below to report a simpe Table to a PDF File. However there are always the quotes ( ' ' ) included in the report as seen in the Picture below. How can I get rid of the ' ' quotes?
cellarray1={'Hello';'Bye'};
cellarray2={'Hola';'Adios'};
import mlreportgen.report.*
import mlreportgen.dom.*
import mlreportgen.utils.*
makeDOMCompilable
t=table(cellarray1, cellarray2);
rpt = Report('Test','pdf');
open(rpt)
table=FormalTable(t);
add(rpt,table)
close(rpt)
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2021년 3월 11일
hi
I don't use those reporting functions , but is there a chance that one of these has like writecell the option to remove quotes like this example :
writecell(new_line', 'out.txt',"QuoteStrings",0);

댓글을 달려면 로그인하십시오.

채택된 답변

Aghamarsh Varanasi
Aghamarsh Varanasi 2021년 3월 17일
Hi,
Post-processing of the table entries can be done to remove the 'quotes' from the strings before adding the table to the report.
For example, strrep can be used to omit quotes.
cellarray1={'Hello';'Bye'};
cellarray2={'Hola';'Adios'};
import mlreportgen.report.*
import mlreportgen.dom.*
import mlreportgen.utils.*
makeDOMCompilable
t=table(cellarray1, cellarray2);
rpt = Report('Test','pdf');
open(rpt)
table=FormalTable(t);
% post processing
tableRows = table.Children(1);
for ii = 1:tableRows.NRows
row = tableRows.Children(ii);
for jj = 1:row.NEntries
rowEntry = row.Entries(jj);
% strrep to omit quotes
rowEntry.Children.Content = strrep(rowEntry.Children.Content, '''', '');
end
end
add(rpt,table)
close(rpt)
Hope this helps

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by