Generate xls file with button

After generating the part records and inserting them in the part, partPlant, PartRev and partWhse tables, I want to add a button in my form to generate an excel file with some default values that I will assign inside my code, and in this way load them through the DTM and update the partOpr and partMtl tables.

Can you please recommend me by which option to do it? I had thought to create a function and then call it in the button properties.
I am new to Epicor. I appreciate your input. Thank you very much.