Refreshing data in HTML for Excel Download

@andreas-kviby I used your code to download excel using HTML. Thanks a lot for that. My problem is if someone presses download button multiple times, data keeps getting accumulated. I need to refresh HTML table every time. How do I refresh data ?

Where is your code?

Without knowing your code…
I assume you will need something like this one…

function myFunction() {
  document.getElementById("myTable").deleteRow(0);
}

-Then first get the table-row-length.
-Use a loop.
-Done.
-Create your new table again.


export async function button11_click_1(event) {
 let map = []

    map = await financial_year_data()
 
    $w("#html3").postMessage(map);
}
    

This is the code where I am passing data to HTML. Problem happens when user presses button multiple time …data gets accumulated

Yes i understand you very well. I designed once a similar HTML-SCRIPT, which do the same, but without J-Query (i do not know J-Query, so i had to code in pure JS). My suggestion would help you, in case of using pure script.
I think in this case i can’t help. If i am honest → i am to lazy to learn J-Query :rofl: at moment.

Is your code from the —> Example-Section of Ziv-Assors post?
I once saw also your posts in there.

Here you will find an example, which has exactly the same problem.
https://www.media-junkie.com/rd-database-manager

How to see the problem?


The same situation like you described…
The more times you click onto the “Excel”-button, the bigger gets the table.

Your HTML-Code will do the same thing, like mine. → Generating table-content.
All you have to do is → first to delete your table, and then reconstruct it with new data, every-time when HTML-component gets its values.

https://www.w3schools.com/jsref/met_table_deleterow.asp

Thanks. You gave me enough hint to solve my problem. Syntax to use in jquery to remove data is
$(“#your table id tr”).remove();

Were you already able to resolve your issue ?

Yes. Thanks.