Varible backed object table download

I want to implement the same functionality as object table→rightClick→Export (View mode), but by using a button onclick. It should still only download the columns which is backed by variable backed column visibility and the same object tables data. Is this possible and how?

An Update, Implemented this using the followig approach.
The parameters used here were as follows -

1.ObjectSet(Backing dataset, can include filters based on requirement),

2.all available columns(Used as header of the export file),

3.since I used variable backed column visibility for the object table, I had the property names for the selected properties which also is used to specific order.

4.rawApiNames which is required because the value for each cell should exactly be retrieved.

5.Now, onclick of the button, if all the parameters passed; we will call a function backed export→csv file is downloaded if everything works as specified.

=>On button click, the function returns a CSV string; the UI downloads it. The exported file includes only the selected columns (similar to ObjectTable export behavior).

Cool! Would love to see the Typescript if you can post it.