+ 1

Flask app-- copy table in Web page to clipboard

I have a table in a webpage with a list of what we have available. Users will need to copy the information to place orders against it. Rather than copying the entire table I would like some code to put it into there clipboard in the correct format. I am unsure if this sits with JavaScript or python? Maybe bootstrap 3(that I'm using) has something in there is file to make easier? Flask version=0.10.1

19th Aug 2020, 11:00 AM
Charlie Crease-huggett
6 Antworten
+ 1
maybe this might help:- Python have a module named "pyperclip" to copy the stuff on clip board but before that you have to extract the row/column first. https://pypi.org/project/pyperclip/
19th Aug 2020, 11:03 AM
Arsenic
Arsenic - avatar
+ 1
Arsenic the flask app retrieves the information from a database, and puts the view into a table, so that shouldn't be an issue. My only other thought might be could you store the view in a record set to not run unnecessary queries against database.
19th Aug 2020, 11:11 AM
Charlie Crease-huggett
0
const copytext = (text) => { let textarea = document.createElement('textarea'); document.body.appendChild(textarea); textarea.value = text; textarea.select(); document.execCommand('copy'); textarea.remove(); } https://code.sololearn.com/WA5HF1OI2FMx/?ref=app
19th Aug 2020, 12:52 PM
Arnesh
Arnesh - avatar
0
Hi Arnesh , thanks for the reply I was hoping to copy the content of an entire table. Is this possible?!
19th Aug 2020, 4:16 PM
Charlie Crease-huggett
0
You can copy text. Pass the entire table text to this function and it will be copied. This function copies text. Now it is upto you how you separate the table data. Note: Copying text means the previous text is gone unless it is saved in a clipboard. But if you really want to give the user the table, what about letting him/her download a .xlsx file generated by the server?
19th Aug 2020, 5:21 PM
Arnesh
Arnesh - avatar
0
Arnesh ok, I can try that, the only reason for note creating a CSV file and passing back to the user was because I thought it'd be a little slow
20th Aug 2020, 10:03 AM
Charlie Crease-huggett