How to get empty string when the cell is empty and sits at the last column
See original GitHub issueDiscussed in https://github.com/exceljs/exceljs/discussions/1921
<div type='discussions-op-text'>Originally posted by kmorte December 3, 2021 Hi
I’m trying to build a json object per row. But rows with an empty cell as the last onw don’t get parsed be the library and then values don’t match with headers.
Thanks.
const book = new ExcelJS.stream.xlsx.WorkbookReader(fileRoute, {
sharedStrings: 'cache',
hyperlinks: 'emit',
worksheets: 'emit',
entries: 'emit'
});
for await (const sheet of book) {
const headers = {};
const values = {};
for await (const row of sheet) {
const model = row.model;
const cells = model.cells;
if(model.number === 1) {
cells.forEach((c, i)=> {
headers[i] = c.value;
});
};
if(model.number !== 1) {
cells.forEach((c, i)=> {
// if the last cell is empty, it does not appear here
values[i] = c.value;
});
};
const item = {};
Object.keys(headers).forEach(h=> {
Object.keys(values).forEach(v => {
if(h === v) {
item[headers[h]] = values[v]
};
});
});
// console.log('item ', item );
};
};
```</div>
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Excel conditional formatting for blank cells - Ablebits
Open the Rule Manager (Conditional Formatting > Manage Rules), make sure the "Blanks" rule is at the top of the list, and tick...
Read more >Excel Formula Master Tricks for Empty Cells, Zeros ... - YouTube
Excel Formula Master Tricks for Empty Cells, Zeros, Zero Length Text String and 'Blanks' EMT 1764.
Read more >How to Apply Conditional Formatting to Blank Cells | Excelchat
Want to learn how to apply conditional formatting to blank cells in Excel? This post will give you an overview of how to...
Read more >Display empty cells, null (#N/A) values, and hidden worksheet ...
By default, data that is hidden in rows and columns in the worksheet is not displayed in a chart, and empty cells or...
Read more >How to use NULL or empty string in SQL - Stack Overflow
17 Answers 17 · 3. SELECT * FROM TableName WHERE columnNAme IS NULL OR RTRIM(columnName) = '' · 2. As Xavier points out,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kmorte
Equivalent to
Equivalent to
Is the result of the following code running what you expect?