Skip to main content

Adding Rows

Adding Rows

One row at a time

const { Table } = require("console-table-printer");

const p = new Table();

p.addRow({ Serial: 1, text: "red wine", value: 10.212 }); // Single row at a time
p.addRow({ Serial: 2, text: "green gemuse", value: 20.0 });
p.addRow({
Serial: 3,
text: "gelb bananen",
value: 100,
is_priority_today: "Y",
});
p.addRow({ Serial: 3, text: "rosa hemd wie immer", value: 100 });
p.printTable();
Screenshot

Batch Row Adding

const { Table } = require("console-table-printer");

const p = new Table();

p.addRows([
// adding multiple rows are possible
{ Item: 3, text: "green color text1", value: 100 },
{ Item: 4, text: "green color text2", value: 300 },
]);
p.printTable();
Screenshot

Chained Row adding

Adding row function can be chained

const { Table } = require("console-table-printer");

const p = new Table();

p.addRow({ Weight: "1kg", text: "red wine", value: 10.212 })
.addRow({ Weight: "1kg", text: "green gemuse", value: 20.0 })
.addRow({
Weight: "2kg",
text: "gelb bananen",
value: 100,
is_priority_today: "Y",
})
.addRow({ Weight: 3, text: "rosa hemd wie immer", value: 100 });
p.printTable();