Skip to main content

to_html

Function to_html 

Source
pub fn to_html(table: &ExportTable, options: &HtmlOptions) -> String
Expand description

Writes the table as HTML.

Column groups become the header’s upper rows, a group’s heading a row of its own, and aggregates rows that say what they are (Sum €7,300.50). Values are the text the grid shows: a page is read, not parsed.

use datagrid_core::{ExportCell, ExportColumn, ExportRow, ExportTable};
use datagrid_export::{HtmlOptions, to_html};

let table = ExportTable {
    columns: vec![ExportColumn::new("note", "Note")],
    rows: vec![ExportRow::Data(vec![ExportCell {
        value: None,
        text: "<b>&</b>".into(),
    }])],
};
let html = to_html(&table, &HtmlOptions::default());
assert!(html.contains("&lt;b&gt;&amp;&lt;/b&gt;"));
assert!(!html.contains("<b>"));