Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Fork of node-excel-export
to use xlsx
instead
of xlsx-style
in order to support hyperlinks and other
features being lost by that fork not staying current.
npm install axles
const excel = require('axles');
// You can define styles as json object
const styles = {
headerDark: {
fill: {
fgColor: {
rgb: 'FF000000'
}
},
font: {
color: {
rgb: 'FFFFFFFF'
},
sz: 14,
bold: true,
underline: true
}
},
cellPink: {
fill: {
fgColor: {
rgb: 'FFFFCCFF'
}
}
},
cellGreen: {
fill: {
fgColor: {
rgb: 'FF00FF00'
}
}
}
};
//Array of objects representing heading rows (very top)
const heading = [
[{value: 'a1', style: styles.headerDark}, {value: 'b1', style: styles.headerDark}, {value: 'c1', style: styles.headerDark}],
['a2', 'b2', 'c2'] // <-- It can be only values
];
//Here you specify the export structure
const specification = {
customer_name: { // <- the key should match the actual data key
displayName: 'Customer', // <- Here you specify the column header
headerStyle: styles.headerDark, // <- Header style
cellStyle: function(value, row) { // <- style renderer function
// if the status is 1 then color in green else color in red
// Notice how we use another cell value to style the current one
return (row.status_id == 1) ? styles.cellGreen : {fill: {fgColor: {rgb: 'FFFF0000'}}}; // <- Inline cell style is possible
},
width: 120 // <- width in pixels
},
status_id: {
displayName: 'Status',
headerStyle: styles.headerDark,
cellFormat: function(value, row) { // <- Renderer function, you can access also any row.property
return (value == 1) ? 'Active' : 'Inactive';
},
width: '10' // <- width in chars (when the number is passed as string)
},
note: {
displayName: 'Description',
headerStyle: styles.headerDark,
cellStyle: styles.cellPink, // <- Cell style
width: 220 // <- width in pixels
}
}
// The data set should have the following shape (Array of Objects)
// The order of the keys is irrelevant, it is also irrelevant if the
// dataset contains more fields as the report is build based on the
// specification provided above. But you should have all the fields
// that are listed in the report specification
const dataset = [
{customer_name: 'IBM', status_id: 1, note: 'some note', misc: 'not shown'},
{customer_name: 'HP', status_id: 0, note: 'some note'},
{customer_name: 'MS', status_id: 0, note: 'some note', misc: 'not shown'}
]
// Define an array of merges. 1-1 = A:1
// The merges are independent of the data.
// A merge will overwrite all data _not_ in the top-left cell.
const merges = [
{ start: { row: 1, column: 1 }, end: { row: 1, column: 10 } },
{ start: { row: 2, column: 1 }, end: { row: 2, column: 5 } },
{ start: { row: 2, column: 6 }, end: { row: 2, column: 10 } }
]
// Create the excel report.
// This function will return Buffer
const report = excel.buildExport(
[ // <- Notice that this is an array. Pass multiple sheets to create multi sheet report
{
name: 'Report', // <- Specify sheet name (optional)
heading, // <- Raw heading array (optional)
merges, // <- Merge cell ranges
specification, // <- Report specification
data: dataset // <-- Report data
}
]
);
// You can then return this straight
res.attachment('report.xlsx'); // This is sails.js specific (in general you need to set headers)
return res.send(report);
// OR you can save this buffer to the disk by creating a file.
v1.0.1
xlsx
from 0.13.x
to 0.18.5
FAQs
Axles - Excel / XLSX reader and parser. Forked from node-excel-export
The npm package axles receives a total of 13 weekly downloads. As such, axles popularity was classified as not popular.
We found that axles demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.