mlreportgen.report.TextFile Class
Namespace: mlreportgen.report
Superclasses: mlreportgen.report.Reporter
Description
Create a reporter to report on text files.
The mlreportgen.report.TextFile class is a handle class.
Creation
Description
creates an empty
reporter = TextFileTextFile reporter object based on a default template. Use its
properties to specify a text file on which to report and to specify report options. You
must specify a text file name to be reported. Adding an empty TextFile
reporter object, that is, one that does not specify a file name, to a report, produces
an error.
creates a
reporter = TextFile(filename)TextFile reporter object with the FileName
property set to filename. Adding this reporter to a report, without any further
modification, adds the text file content to the generated report. Use the reporter's
properties to customize the report options.
creates a reporter = TextFile(p1,v1,p2,v2,...)TextFile reporter and initializes properties
(p1,p2,...) to the specified values
(v1,v2,...).
Properties
Path or name of the text file, specified as a character vector or string scalar.
Example: tf.FileName = "Name of File"
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
Whether to import the file as a DOM Paragraph or DOM
Text object, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — Import the file as aDOM Paragraphobject. The input is broken into paragraphs at values set by theParaSepproperty. UseParagraphFormatterproperty whose value is aDOM Paragraphobject to format theDOM Paragraphobjects.0(false) — Import the text file as aDOM Textobject. UseTextFormatterproperty whose value is aDOM Textobject to format theDOM Textobject.
Example: "ImportFileAsParagraph","false"
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: logical
Paragraph separator, specified as a character vector or string scalar. Use this
property to specify the separator used to break the input into paragraphs. You can use
any separator. For example, newline separates the input text at a
line break and wraps the text into paragraphs.
Example: "ParaSep","char(10)"
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
If the ImportFileAsParagraph property for the
TextFile reporter is true, the reporter appends
a plain text paragraph to a copy of this object and appends it to the report. Use mlreportgen.dom.Paragraph
object properties to format a plain text paragraph by setting the properties of the
default paragraph or by replacing the default paragraph with a custom paragraph. Content
that you add to the default or replacement paragraph appears before the content of the
generated report.
Example: "ParagraphFormatter.Color","red"
Attributes:
GetAccess | public |
SetAccess | public |
If the ImportFileAsParagraph property for the
TextFile reporter is false, the reporter appends
a plain text content to a copy of this object and appends it to the report. Use the
mlreportgen.dom.Text object properties to format a plain text
content. Content that you add to the default appears before the content of the generated
report.
Example: "TextFormatter.Color","red"
Attributes:
GetAccess | public |
SetAccess | public |
Source of the template for this reporter, specified in one of these ways:
Character vector or string scalar that specifies the path of the file that contains the template for this reporter
Reporter or report whose template this reporter uses or whose template library contains the template for this reporter
Document Object Model (DOM) document or document part whose template this reporter uses or whose template library contains the template for this reporter
The specified template must be the same type as the report to which you
append this reporter. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template.
If the TemplateSrc property is empty, this reporter uses the
default reporter template for the output type of the report.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Dependent | true |
Name of the template for this reporter, specified as a character vector or string scalar.
The template for this reporter must be in the template library of the template specified by
the TemplateSrc property of this reporter.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
Hyperlink target for this reporter, specified as a character vector or string scalar
that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A character vector or string scalar
value converts to a LinkTarget object. The link target immediately
precedes the content of this reporter in the output report.
Attributes:
GetAccess | public |
SetAccess | public |
Methods
| Method | Purpose |
|---|---|
mlreportgen.report.TextFile.createTemplate |
Create reporter template
Input Arguments
Return Values
For more information, see the method for
the |
mlreportgen.report.TextFile.customizeReporter |
Create reporter from
Input Arguments
Return Values
For more information, see the method for
the |
mlreportgen.report.TextFile.getClassFolder |
Get location of folder that contains
Return Values
For more information, see the method for
the |
copy |
Create copy of reporter object and make deep copies of property values
Input Arguments
Return Values
For more information, see the method for
the |
getImpl |
Get implementation of reporter
Note You cannot add content to the reporter after calling this method. Input Arguments
Return Values
For more information, see the method for
the |
Examples
Create a report from text file as a paragraph.
First, create a text file and save it as my_script.txt to use
with this example. Next, import the report API namespaces so that you do not have to use
long fully qualified class names.
import mlreportgen.report.*Create a PFD report.
rpt = Report("MyReport","pdf"); open(rpt);
Create an empty chapter.
chap = Chapter("TextFile Reporter");Create a TextFile reporter. Specify a paragraph separator so the
report creates a new paragraph at each newline character.
rptr = TextFile("my_script.txt");
rpt.ParaSep = [newline newline];Append the reporter to the chapter and append the chapter to the report.
append(chap,rptr); append(rpt,chap);
Close and view the report.
close(rpt); rptview(rpt);
Version History
Introduced in R2023a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)