Banana.Report.ReportElement

Questa documentazione è superata

La documentazione più completa e aggiornata è quella di Banana Contabilità Plus: Provalo subito

In this article

The class Banana.Report.ReportElement represents the report itself and every element in the report, like sections, paragraphs, tables, texts and the report itself.

Once you create a new report through the method Banana.Report.newReport() you can start adding sections, paragraphs, texts, tables and so on. 

When you add an element with one of the add methods, you get as return value an object of type

Elments as a container of other elements.

Banana.Report.ReportElement that represents the added element.
To this object you can add further elements and by this way construct the structure of the report.

Report
   +  Paragraph
   +  Table
      +  Row
         + Cell
         + Cell
      +  Row
         + Cell
         + Cell
      ...

Even if this interface enable you to add tables to text elements or columns to paragraphs, the result will be undefined.

Formatting like text size, text color, margins, and so on are set separately through a Banana.Report.ReportStyleSheet object.

 

Methods   

addClass(classes)

Add classes to the node. A class binds the element to the corresponding class style definend in Banana.Report.ReportStyleSheet as used in CSS Stylesheets.

 

addSection([classes])

Add a section and return the created section as a Banana.Report.ReportElement object.

You can add sections only to sections, cells, captions, headers or footers.

 

addParagraph([text, classes])

Add a paragraph and return the created paragraph as a Banana.Report.ReportElement object.

You can add paragraphs only to sections, cells, captions, headers or footers.

 

addText(text [, classes])

Add a text node and return the create text as a Banana.Report.ReportElement object.

You can add texts only to sections, paragraphs, cells, captions, headers or footers.

 

addTable([classes])

Add a table and return the created table as a Banana.Report.ReportElement object.

You can add tables only to the report or sections.

 

addColumn([classes])

Add a column and return the created column as a Banana.Report.ReportElement object.

You can add columns only to tables.

 

addRow([classes])

Add a row and return the created row as a Banana.Report.ReportElement object.

You can add rows only to tables, table headers or table footers.

 

addCell([span])

Add an empty cell and return the created cell as a Banana.Report.ReportElement object.

You can add cells only to rows. You can span cells over columns but not over rows.

 

addCell(text [,classes, span])

Add a cell to the node and return the created cell as a Banana.Report.ReportElement object.

You can add cells only to rows.You can span cells over columns but not over rows.

 

addLineBreak()

Add a line break and return the created line break as a Banana.Report.ReportElement object.

You can add line breaks only to paragraphs or cells.

 

addPageBreak()

Add a page break node and return the created page beak as a Banana.Report.ReportElement object.

You can add line breaks only to the report or sections.

 

addImage(path [,classes])

Add an image and return the created image as a Banana.Report.ReportElement object.

You can add texts only to sections, paragraphs, cells, captions, headers or footers.

The parameter path can be absolute or relative to the script path.

 

addFieldPageNr([classes])

Add a field with containg the page number and return the created field as a Banana.Report.ReportElement object.

You can add this field only to sections, paragraphs, cells, captions, headers or footers.

 

getWatermark()

Return the watermak element.

Only the report has a watermak element.

 

getHeader()

Return the header of the element. 

Only tables and the report have an header element.

 

getFooter()

Return the footer of the element. 

Only tables and the report have a footer element.

 

getCaption()

Return the caption of the element. 

Only tables have a caption element.

 

getTag()

Return the tag of the element, like 'body', 'p', 'table', 'td' and so on.

 

setOutline(level)

Set the outline level, this is used to create the index when exporting to pdf.

 

setBookmark(bookmark)

Set a bookmark (or anchor), this is used in conjunction with setLink().

 

setLink(bookmark)

Set a link to a bookmark. See setBookmark().

 

setPageBreakBefore()

Set to insert a page break before the element.

 

setStyleAttribute(attr_name, attr_value)

Set a style attribute to the element. Attributes ids and values follow the CSS specification. This attibute correspont to the inline styles in Css.

paragraph.setAttribute("font-size", "24pt");
 

setStyleAttributes(attributes)

Set style attributes to the element. Attributes ids and values follow the CSS specification. Those attributes correspond to the inline styles in Css.

paragraph.setAttribute("font-size:24pt;font-weight:bold;");

 

setUrlLink(link)

Set a link to an external file (file://...) or a web page (http://....).

To the element the class "link" is automatically added.