html-to-xlsx
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -83,2 +83,5 @@ const path = require('path') | ||
// xlsxColumnIdx is global column index in table | ||
let xlsxColumnIdx = 0; | ||
for (let cIdx = 0; cIdx < row.length; cIdx++) { | ||
@@ -112,4 +115,4 @@ const cellInfo = row[cIdx] | ||
if (cellInfo.width) { | ||
if (!maxWidths[cIdx]) { | ||
maxWidths[cIdx] = 0 // default width | ||
if (!maxWidths[xlsxColumnIdx]) { | ||
maxWidths[xlsxColumnIdx] = 0 // default width | ||
} | ||
@@ -119,11 +122,20 @@ | ||
if (pt > maxWidths[cIdx]) { | ||
if (pt > maxWidths[xlsxColumnIdx]) { | ||
const width = pt / cellSpan | ||
maxWidths[cIdx] = width | ||
// we need to set column width before row commit in order | ||
// to make it work | ||
sheet.getColumn(cIdx + 1).width = width | ||
// only remember max column widths for single columns | ||
if (cellSpan == 1) { | ||
maxWidths[xlsxColumnIdx] = width | ||
// we need to set column width before row commit in order | ||
// to make it work | ||
sheet.getColumn(xlsxColumnIdx + 1).width = width | ||
} else if (!Boolean(sheet.getColumn(xlsxColumnIdx + 1).width)) { | ||
// only set width on multi colspan if not already defined | ||
sheet.getColumn(xlsxColumnIdx + 1).width = width | ||
} | ||
} | ||
} | ||
// increment global column index by cellSpan to track setting of column width | ||
xlsxColumnIdx += cellSpan; | ||
const cell = sheet.getCell(`${context.currentRowInFile + 1}`, `${currentCellOffsetsPerRow[context.currentRowInFile] + 1}`) | ||
@@ -130,0 +142,0 @@ |
{ | ||
"name": "html-to-xlsx", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Jan Blaha", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114250
2427