My problem is that I try to do a print, print a database table, to be able to pass it to official sheets, basically print the table, I tried with
<button onclick="window.print()" class="btn btn-success btn-raised btn-xs">Imprimir</button>
It prints it for me but it prints all the tabs and I only want it to print the table that contains the records of a database, and to be able to select the fields that are printed, since I want to avoid printing the buttons as well, I attach a reference image:
Normally the printing of data is handled by the server side, in your case it should be done by PHP and not by javascript.
For that you must make use of libraries that already do this work such as PHPSpreadSheet or DOMPDF
You can review its documentation and if you have any questions remember to ask another question and not continue in the same thread.