This example shows how to add sparklines to a report table.
Import the Report and DOM API namespaces so that you do not have to use long, fully qualified names.
Create a table that contains the sales data from January to June for four companies from the list of company names, the sales data, and the names of the months. The rows of the sales data matrix correspond to the companies and the columns correspond to the months.
The "companyNames" array is the first column, followed by columns for each month of sales data. The final column, "Trends", is empty. In this example, you will populate this column with the sparkline for each company.
Create a new report titled "StockMarketReport" and specify the output format as PDF.
Create a MATLABTable reporter object from the table, tbl.
Loop through each row in the table and perform the following operations to add sparklines from the sales data of each company.
Create a new table entry for the current row.
Create a sparkline for the sales data of the current company.
Get a snapshot image of the sparkline to include in the report.
Create a DOM image object using the captured snapshot image.
Append the DOM image to the table entry (this adds the sparkline to the cell).
Add the table entry to the corresponding row in the MATLAB table.
Append the table with sparklines to the report.
Close and view the report.