Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-to-xlsx

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-to-xlsx - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

lib/stylesMap.js

@@ -27,3 +27,3 @@ const utils = require('./utils')

},
wrapText: (cellInfo) => cellInfo.wrapText === 'scroll',
wrapText: (cellInfo) => cellInfo.wrapText === 'scroll' || cellInfo.wrapText === 'auto',
fill: (cellInfo) => {

@@ -30,0 +30,0 @@ if (utils.isColorDefined(cellInfo.backgroundColor)) {

@@ -27,2 +27,4 @@ const util = require('util')

const currentCellOffsetsPerRow = []
const pendingCellOffsetsPerRow = []
const usedCells = []
let currentRowInFile = 0

@@ -38,2 +40,11 @@

if (
pendingCellOffsetsPerRow[currentRowInFile] === undefined ||
pendingCellOffsetsPerRow[currentRowInFile].length === 0
) {
pendingCellOffsetsPerRow[currentRowInFile] = [{
pending: 0
}]
}
const allCellsAreRowSpan = table.rows[rIdx].filter(c => c.rowspan > 1).length === table.rows[rIdx].length

@@ -85,3 +96,7 @@

const cell = sheet.cell(currentRowInFile + 1, currentCellOffsetsPerRow[currentRowInFile] + 1)
let startCell = cell.columnNumber()
let endCell = cell.columnNumber()
usedCells[`${cell.rowNumber()},${cell.columnNumber()}`] = true
if (cellInfo.type === 'number') {

@@ -120,5 +135,13 @@ cell.value(parseFloat(cellInfo.valueText))

// column number is returned as 1-base
const startCell = cell.columnNumber()
const endCell = startCell + cellIncrement
startCell = cell.columnNumber()
endCell = startCell + cellIncrement
for (let r = startRow; r <= endRow; r++) {
for (let c = startCell; c <= endCell; c++) {
if (usedCells[`${r},${c}`] == null) {
usedCells[`${r},${c}`] = true
}
}
}
// range takes numbers as 1-based

@@ -146,3 +169,39 @@ const range = sheet.range(

currentCellOffsetsPerRow[currentRowInFile + r] += cellSpan
if (
pendingCellOffsetsPerRow[currentRowInFile + r] == null ||
pendingCellOffsetsPerRow[currentRowInFile + r].length === 0
) {
pendingCellOffsetsPerRow[currentRowInFile + r] = [{
pending: 0
}]
}
// don't increase offset when previous cell was not set, instead reserve it for later.
// this makes some rowspan/colspan layout to work properly
if (usedCells[`${currentRowInFile + r + 1},${Math.max(startCell - 1, 1)}`] != null) {
currentCellOffsetsPerRow[currentRowInFile + r] += cellSpan
const currentPending = pendingCellOffsetsPerRow[currentRowInFile + r][0]
if (
currentPending &&
currentPending.pending !== 0 &&
Math.max(endCell + 1) >= currentPending.lastCellStart
) {
currentCellOffsetsPerRow[currentRowInFile + r] += currentPending.pending
pendingCellOffsetsPerRow[currentRowInFile + r].shift()
}
} else {
const lastPending = pendingCellOffsetsPerRow[currentRowInFile + r][pendingCellOffsetsPerRow[currentRowInFile + r].length - 1]
if (lastPending && lastPending.lastCellStart != null && lastPending.lastCellStart !== startCell) {
pendingCellOffsetsPerRow[currentRowInFile + r].push({
lastCellStart: startCell,
pending: cellSpan
})
} else if (lastPending) {
lastPending.lastCellStart = startCell
lastPending.pending += cellSpan
}
}
}

@@ -149,0 +208,0 @@ }

{
"name": "html-to-xlsx",
"version": "1.1.0",
"version": "1.1.1",
"author": {

@@ -48,3 +48,3 @@ "name": "Jan Blaha",

"phantomjs": "1.9.17",
"puppeteer": "1.11.0",
"puppeteer": "1.13.0",
"should": "13.2.1",

@@ -51,0 +51,0 @@ "standard": "11.0.0",

@@ -21,7 +21,9 @@ # html-to-xlsx

(async () => {
async function run () {
const stream = await conversion(`<table><tr><td>cell value</td></tr></table>`)
stream.pipe(fs.createWriteStream('/path/to/output.xlsx'))
})()
}
run()
```

@@ -40,3 +42,3 @@

- `rowspan` - numeric value that merges current row with rows below.
- `overflow` - the excel cell will have text wrap enabled if this is set to scoll.
- `overflow` - the excel cell will have text wrap enabled if this is set to `scroll` or `auto`.

@@ -75,5 +77,7 @@ ## Constructor options

(async () => {
async function main () {
const stream = await conversion(/* html */, /* extract options */)
})()
}
main()
```

@@ -80,0 +84,0 @@

Sorry, the diff of this file is too big to display

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