Search code examples
javascriptemailgrailsexport-to-excel

Save Generated File to local disc while using export funcitonality in Grails


Requirement: I have a page wherein tabular data is displayed. On click of a button, this data should be exported to an excel, attached to a mail and sent.

What I have done till now: I have achieved export to excel functionality in Grails using the export plugin.

And Mail Functionality using outlook Object in javascript as in below post. Outlook message to pop up before mail is sent in grails

However when I use OutlookObject I mention the attachment as below.

var attach1 = "c:\\temps\\test.txt"

In this case the attachment is taken from the local drive.

Question: While I export my tabular data to an excel, Is there a way to save the file to the local drive so that the attachment can be read from the same location and sent in the mail as an attachment.

Thanks in advance!


Solution

  • Unfortunately you can't tell a browser where to save something or ask it for the location of a recently saved file so not really. What you could do is have the file exported and saved both to the users hard drive and somewhere online and use the online version when sending the email.