pofider / html-to-xlsx Goto Github PK
View Code? Open in Web Editor NEWnode.js based html to xlsx transformation
License: MIT License
node.js based html to xlsx transformation
License: MIT License
Caused by long table with 1000 rows
I've been banging my head over this for about a week now and I can't seem to find a solution.
I'm on OSX Sierra with phantomjs-prebuilt in my node_modules and I get the following error:
Error: connect ECONNREFUSED 127.0.0.1:49837
at Object.exports._errnoException (util.js:1023:11)
at exports._exceptionWithHostPort (util.js:1046:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
And this is the code:
let html = pug.renderFile(Utils.root('src/templates/test.pug'), { data: data });
convertToExcel(html, (err, stream) => {
if (err) {
console.error(err);
throw err;
}
res.setHeader('Content-Type', 'application/octet-stream');
res.setHeader('Content-Disposition', 'attachment; filename=report.xlsx');
stream.pipe(res);
}
I've tried several different configurations with no success so far.
Can you provide any insight?
demo of the problem here.
the problem is mainly because this line, when last cell has a rowspan different than default (1
), the curr_row
ends with a value that points to an unexisting row.
this can be fixed with some conditions but the bigger problem is that this case is special.
this is the browser output for this case:
as you can see the cells of second row starts at the position of first row, so this would require to have an special mapping of rows/cells to achieve the same behaviour of browsers.
It would be great is cell types were supported. Eg. Number, text, date, ...
Currently everything is a string.
It would be great if font family was supported
I want to give my custom name for downloaded pdf Latest JSreport 1.8.2
Hello Sir, i downloaded jsreport-win.zip(1.8.2) file for installing in windows 10. Using jsreport configure command in command prompt i configured and one dev.config.json file was created. in this configuration i have given 3002 as my port number.After this, using jsreport win-install command i installed jsreport output showed your jsreport service is running. Again i typed jsreport start command it is throwing error and the service which was installed is not working with that port number.Can you please help me how to install this latest version with User required port number[ex : 3002]. And also i am using old version jsreport and i want to upgrade engines and receipes also in my visual studio[.net]. Tell me how to upgrade relevant nuget packages for supporting this latest version.
Adding support for gridlines and sheet rtl direction would be very much appreciated.
rtl_and_gridlines.xlsx
I've been using this package for a while on AWS Lambda on the pre 1.x version. I was looking to update my package to the latest version. But I'm having trouble with running puppeteer in AWS Lambda I've search for various solutions online but haven't found one yet that works. Was wondering if you had a possible solution or an alternative. It all started with this error:
Failed to launch chrome!\n/var/task/node_modules/puppeteer/
I've tried using puppeteer-core
, puppeteer-lambda
and varios other things I've found online.
currently my html page having 3 tables
after converting html to excel 3 tables is showing in 3 different sheets i want it in single sheet.
var conversion = require ('html-to-xlsx') ();
var fs = require('fs');
fs.readFile('./Sample9.html', 'utf8', function (err,data) {
if (err) return console.log(err);
conversion(data,function(err,stream) {
stream.pipe(res);
})
});
I am trying to read the html file(ie file name Sample9.html) place in my root directory and convert it into xlsx , which is not happening can any one help me with this issue
as reported here and with a demo available here, the second row of excel has the first column width matching the width of the first row (one cell merged from 3 cells). since browsers does not treat this kind of content in the same way (they treat first cell of second row as something standalone from the previous row width) i would say that it is the best if we can match the browser behaviour.
current output:
browser output:
Workaround is to use dedicated-process
strategy.
require("html-to-xlsx")({ strategy: "dedicated-process" });
This throws error where it should rather callback it
<table>
<tr>Hello</tr>
</table>
<table>
<tr>
<td>1</td>
<td rowspan="2">2</td>
</tr>
<tr>
<td>3</td>
</tr>
</table>
cell 3 is not shown in the xlsx file
It would be quite good if it has support for rowspan and colspan for table layouts HTML .
Thank You,
Need to find a way how to put ampersand in to the xlsx.
Neither of &
, &
, &amp;
currently works.
In our implementation we came across a bug in the rowspan support. It seems when multiple rowspans exist for the same row (i.e., multiple columns span multiple rows), the Excel document that is rendered either is corrupted or has cell values not in the correct order.
I'm currently working on a fix for this, but wanted to document the issue for others and have a issue to attach to the PR.
(similar to #19) second and third cells of first row has more height than normally when using rowspan
in first cell. since browsers does not treat this kind of content in the same way (they treat cell height as something standalone from the previous cell height) we should match the browser behaviour.
demo of issue here
current output:
browser output:
Conversion crashes when there is more than ~400k cells in the table. Mostly because of the memory limits. I have tried several approaches to fix this, but don't have an ultimate solution for this yet.
phantom.eval
to return cells' values and styles back to the phantom and then to node process. The return from phantom.eveal
crashes if you have ~200k cells.I was able to get over this with batch processing phantom.eval
on just 1000 rows.
I was able to decrease the memory impact with just storing a style id for each cell and styles separately.
Calling phantomjs.page.close()
after each phantomjs.page.eval
. helps a bit.
With the previous fixes, it still doesn't process more than 800k cells.
The final solution could be to write the partial cell information batches to a file. However the phantomjs memory management is really strange and the solution doesn't need to necessarily work.
https://playground.jsreport.net/w/anon/mzBXYDAw
and it failed to print page number for Recipe.ChromePdf
Please help.
i have this error when i'm trying to use the example.
what should i do?
Hello, I am trying to merge two or three columns using Colspan, it is not coming,
and i want to display in multiple table in the excel instead of showing all the data in a single table[ multiple grids in Excel], is it possible to do that one
When I'm running 'npm install' cmd, got this error
and here I found this
The ssh its not equals
[email protected]/pofider/html-to-xlsx.git -> ssh in error
[email protected]:pofider/html-to-xlsx.git -> ssh expected
Table Caption tag is not supporting...Any alternative.?
Hello, I applied fix for issue about colspan and I faced with some strange behavior.
If template contains only one row with colspan, all is fine:
But, if template contains two row with rowspan, width is not correct:
Thanks in advance!
Hi,
Moment 2.29.3 has a regular expression DOS security vulnerability and fix to this is available in 2.29.4. Are there plans to upgrade the version of moment used by html-to-xlsx library
In may case I need to create that table:
one | two | test | test |
one | two | ||
one | two |
The table output is missing the values that comes after the first row, like this:
one | two | test | test |
If I'll remove one of the "rowspan" it will work correctly.
And if I put the rowspan as the first tds it also will work correctly.
Any suggestion?
"message":"Error: Invalid character (\u001f) in string: \n adri\u001f_\n
at index 17\n at XMLStringifier.module.exports.XMLStringifier.assertLegalChar
(E:\\approot\\node_modules\\xmlbuilder\\lib\\XMLStringifier.js:150:15)\n at
XMLStringifier.assertLegalChar (E:\\approot\\node_modules\\xmlbuilder\\lib\\XMLStringifier.js:4:59)\n at
XMLStringifier.module.exports.XMLStringifier.eleText (E:\\approot\\node_modules\\xmlbuilder\\lib\\XMLStringifier.js:27:19)\n at new
XMLText (E:\\approot\\node_modules\\xmlbuilder\\lib\\XMLText.js:19:35)\n at XMLElement.module.exports.XMLNode.text
(E:\\approot\\node_modules\\xmlbuilder\\lib\\XMLNode.js:168:15)\n at XMLElement.module.exports.XMLNode.node
(E:\\approot\\node_modules\\xmlbuilder\\lib\\XMLNode.js:160:15)\n at XMLElement.module.exports.XMLNode.element
(E:\\approot\\node_modules\\xmlbuilder\\lib\\XMLNode.js:103:28)\n at XMLElement.module.exports.XMLNode.ele
(E:\\approot\\node_modules\\xmlbuilder\\lib\\XMLNode.js:271:19)\n at SharedStrings.toxml
(E:\\approot\\node_modules\\msexcel-builder-extended\\lib\\msexcel-builder.js:299:10)\n at Workbook.save
(E:\\approot\\node_modules\\msexcel-builder-extended\\lib\\msexcel-builder.js:831:75)\n at Workbook.save
(E:\\approot\\node_modules\\msexcel-builder-extended\\lib\\msexcel-builder.js:7:59)\n at tableToXlsx
(E:\\approot\\node_modules\\html-to-xlsx\\lib\\conversion.js:113:14)\n at icb
(E:\\approot\\node_modules\\html-to-xlsx\\lib\\conversion.js:51:9)\n at
E:\\approot\\node_modules\\html-to-xlsx\\lib\\serverStrategy.js:43:13\n at
E:\\approot\\node_modules\\phantom-workers\\lib\\phantomManager.js:102:9\n at IncomingMessage.<anonymous>
(E:\\approot\\node_modules\\phantom-workers\\lib\\phantomWorker.js:134:13)\n at IncomingMessage.emit (events.js:117:20)"
You have
...restOptions,
html: tmpHtmlPath,
scriptFn: conversionFactory.getScriptFn()
I want to add:
headless: true,
slowMo: 100,
args: amIRoot() ? ['--no-sandbox', '--disable-setuid-sandbox'] : undefined,
But I need a few options to be passed to puppeteer. Please direct me to where in the lib to make the adjustment, or let know if there's another way to do this.
Just started using this package...pretty good!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.