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?
    0_1520699664954_upload-f499dc5e-dc2a-4922-ab14-99c8e1a95c75


  • administrators

    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.


  • administrators

    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.


  • administrators

    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 td with different colspan numbers so there is a chance that something is wrong there, html to xlsx conversion will always fail if the cells does not match or have some inconsistency, since you are also using javascript to modify the tables then there are a lot of points in which the table could result in a malformed structure.
    • 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 (HyperLink, 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?


  • administrators

    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?

    all information we have at the moment for html-to-xlsx recipe lives here in docs and in github (1, 2) (where you can inspect our source code to better know how it works)



  • Thank you!


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.