New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@jsreport/jsreport-xlsx

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsreport/jsreport-xlsx - npm Package Compare versions

Comparing version 4.0.2 to 4.1.0

17

lib/cellUtils.js
const { col2num } = require('xlsx-coordinates')
const CELL_REG_REGEXP = /^(?:('?(?:\[([A-Za-z0-9_. ]+\.xlsx)\])?([A-Za-z0-9_. ]+)'?)!)?(\$?[A-Z]+)(\$?\d+)$/
// allows to parse cell expressions like:

@@ -10,5 +12,7 @@ // - B6, $B6 (locked column), B$6 (locked row), $B$6 (locked column and row)

// result: <complete ref from left>:<complete ref from right>
// it is returned from a fn because it needs to use the global flag on regexp,
// and we can not reuse the same regexp instance safely, it needs to be a new one for execution
const getRangeOrMultiCellRefExpressionRegexp = () => /((?:'?(?:\[(?:[A-Za-z0-9_. ]+\.xlsx)\])?(?:[A-Za-z0-9_. ]+)'?!)?(?:\$?[A-Z]+\$?\d+:))?((?:'?(?:\[(?:[A-Za-z0-9_. ]+\.xlsx)\])?(?:[A-Za-z0-9_. ]+)'?!)?(?:\$?[A-Z]+\$?\d+))/g
function parseCellRef (cellRef, startCellRef) {
function parseCellRef (cellRef, parsedStartCellRef) {
// parses single cell ref like:

@@ -18,4 +22,3 @@ // B6, $B6 (locked column), B$6 (locked row), $B$6 (locked column and row)

// [WorkbookName.xlsx]SheetName!B6, '[WorkbookName.xlsx]SheetName'!B6 (workbook name reference) and variants with locked columns and rows
const cellRefRegexp = /^(?:('?(?:\[([A-Za-z0-9_. ]+\.xlsx)\])?([A-Za-z0-9_. ]+)'?)!)?(\$?[A-Z]+)(\$?\d+)$/
const matches = cellRef.match(cellRefRegexp)
const matches = cellRef.match(CELL_REG_REGEXP)

@@ -46,6 +49,6 @@ if (matches == null || matches[4] == null) {

if (matches[3] == null && startCellRef != null) {
workbookName = startCellRef.workbookName
sheetName = startCellRef.sheetName
sensitiveName = startCellRef.sensitiveName
if (matches[3] == null && parsedStartCellRef != null) {
workbookName = parsedStartCellRef.workbookName
sheetName = parsedStartCellRef.sheetName
sensitiveName = parsedStartCellRef.sensitiveName
}

@@ -52,0 +55,0 @@

@@ -29,3 +29,3 @@

if (concatenating) {
if (elements[i].parentNode.previousSibling.localName === 'r') {
if (elements[i].parentNode.previousSibling?.localName === 'r') {
validSiblings = elements[i].parentNode.previousSibling === elements[i - 1].parentNode

@@ -32,0 +32,0 @@ } else {

@@ -170,3 +170,6 @@ const path = require('path')

if (tEls[0].textContent.endsWith(':')) {
if (tEls.length === 1) {
const expectedRegexp = /^{{xlsxColAutofit( [^}]*)?}}$/
shouldRemoveComment = expectedRegexp.test(tEls[0].textContent)
} else if (tEls[0].textContent.endsWith(':')) {
const remainingText = tEls.slice(1).map((el) => el.textContent).join('')

@@ -681,6 +684,6 @@ const expectedRegexp = /^\r?\n?{{xlsxColAutofit( [^}]*)?}}$/

formulaEl.textContent = `{{xlsxSData type='formula' originalCellRef='${cellRef}' originalFormula='${formula}'`
formulaEl.textContent = `{{xlsxSData type='formula' originalCellRef='${cellRef}' originalFormula='${jsSingleQuoteEscape(formula)}'`
if (sharedFormula?.type === 'source') {
formulaEl.setAttribute('ref', `{{xlsxSData type='formulaSharedRefRange' originalSharedRefRange='${sharedFormula.sourceRef}'}}`)
formulaEl.setAttribute('ref', `{{xlsxSData type='formulaSharedRefRange' originalSharedRefRange='${jsSingleQuoteEscape(sharedFormula.sourceRef)}'}}`)
}

@@ -1294,1 +1297,13 @@

}
function jsSingleQuoteEscape (string) {
return ('' + string).replace(/[']/g, function (character) {
// Escape all characters not included in SingleStringCharacters and
// DoubleStringCharacters on
// http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
switch (character) {
case "'":
return '\\' + character
}
})
}

@@ -12,3 +12,3 @@ const { response } = require('@jsreport/office')

res.content = xlsxOutputPath
await res.output.update(Buffer.from(xlsxOutputPath))

@@ -15,0 +15,0 @@ xlsxOutputPath = await transform(reporter, definition, req, res)

@@ -13,3 +13,4 @@ const fs = require('fs')

const xlsxOutputContent = await fs.promises.readFile(res.content)
const resContent = await res.output.getBuffer()
const xlsxOutputContent = await fs.promises.readFile(resContent)
req.data.$xlsxTemplate = await parseXlsx(xlsxOutputContent)

@@ -20,2 +21,3 @@

req.context.asyncHandlebars = true
const contentString = await reporter.templatingEngines.evaluate({

@@ -30,10 +32,17 @@ engine: req.template.engine,

}, req)
req.context.asyncHandlebars = false
// we need to call afterTemplatingEnginesExecutedListeners to ensure the assets are extracted
const fakeRes = { content: Buffer.from(contentString) }
const fakeRes = reporter.Response(`xlsx-transformation-${req.context.id}`)
await fakeRes.output.update(Buffer.from(contentString))
await reporter.afterTemplatingEnginesExecutedListeners.fire(req, fakeRes)
let content
try {
content = JSON.parse(fakeRes.content.toString())
content = (await fakeRes.output.getBuffer()).toString()
content = JSON.parse(content)
} catch (e) {

@@ -40,0 +49,0 @@ throw reporter.createError('Error parsing xlsx content, aren\'t you missing {{{xlsxPrint}}}?', {

{
"name": "@jsreport/jsreport-xlsx",
"version": "4.0.2",
"version": "4.1.0",
"description": "jsreport recipe rendering excels directly from open xml",

@@ -32,3 +32,3 @@ "keywords": [

"dependencies": {
"@jsreport/office": "4.0.0",
"@jsreport/office": "4.1.0",
"@xmldom/xmldom": "0.8.6",

@@ -50,6 +50,6 @@ "html-entities": "2.4.0",

"devDependencies": {
"@jsreport/jsreport-assets": "4.0.2",
"@jsreport/jsreport-assets": "4.1.0",
"@jsreport/jsreport-components": "4.0.0",
"@jsreport/jsreport-core": "4.1.0",
"@jsreport/jsreport-data": "4.0.0",
"@jsreport/jsreport-core": "4.2.0",
"@jsreport/jsreport-data": "4.1.0",
"@jsreport/jsreport-handlebars": "4.0.1",

@@ -56,0 +56,0 @@ "@jsreport/jsreport-jsrender": "4.0.0",

@@ -10,2 +10,10 @@ # @jsreport/jsreport-xlsx

### 4.1.0
- performance optimizations
- remove the xlsxColAutofit comment also if there is no more text in the comment
- fix concat tags logic in some cases
- internal changes to support new `response.output` api
- fix xlsx with formulas stored with `'` string delimiters
### 4.0.2

@@ -12,0 +20,0 @@

@@ -549,3 +549,5 @@ /* eslint no-unused-vars: 0 */

return optionsToUse.fn(this, { data: newData })
const result = optionsToUse.fn(this, { data: newData })
return result
}

@@ -552,0 +554,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc