API to insert report elements
Is there any API to insert a report element? For example, in the palyground sample of "Orders with data fetch script", is there any API to add a table?
hi, hmm sorry i'm not sure what exactly you are trying to do, can you explain it in other way?
I tried to render an HTML to excel with html-to-xlsx recipe but failed. It's obviously that I must follow some rules to create an HTML table, otherwise I could not use html-to-xlsx recipe. So what I asked is an API to create a table than typing html code directly.
hmm in most cases the normal html table structure has worked, can you try to upload the source that you were trying to convert here?
I create a teamplate named as test. Here is the link https://playground.jsreport.net/studio/workspace/H1MDbFStf/4 . It's an HTML generated from a legacy product.
wow, your example is too big for me to analyze in full but here are some things that i noticed:
- html to xlsx recipe only takes the first table that it founds for the conversion, your example has many tables so only one (the first) will be processed
- the table that you are using probably is malformed, you have a lot of columns
- we have a bug about using rows with just one cell + colspan, and according to your source you have many of those cases
- your html source is using some tags (
AppCommand) that i'm not sure that phantom event recognizes
so the TL;DR is that there are a lot of things to check and change here, so right now if you try the same output with no modification it won't work at all, but it is not because we have some special structure for the html table, just that the table that you are trying to convert is too legacy.
That's the reason that I ask for an API to create a table. It's more flexible to write HTML code that we may break the rule to build a table that supported. Thanks for reviewing that HTML. BTW, do you have document about that recipe?
an API for creating the table would not solve the problem, because there is no way for us to create such API, unfortunately it will require deep knowledge of what is compatible in the specific engine that works under the hood. honestly there is nothing special in html-to-xlsx to justify the creation of an API, we just parse html table and evaluate each cell, of course the cells need to match with other rows but i think that it is common sense to require that. maybe in future we can improve the error message to better highlight the problem found in the evaluated html
other reason for such API not being possible is that what it is supported and what is not in html depends on the engine that it is used under the hood, right now the html-to-xlsx recipe uses phantomjs to parse the table but in jsreport v2 the engine will be selectable so you will be able to select chrome or phantomjs.
your case is special because there are other things to fix first, i don't think an API for table would solve that. in any case you will need to still change the way that you are using html-to-xlsx recipe today.
do you have document about that recipe?