
This can be achieved in any JavaScript framework. Rest.ajaxPromise('GET', REST_DOWNLOAD_URL). Many times when we have some reporting or an admin panel application we need to download data in an excel file.

Verify that the file has not been corrupted and that the file extension matches the file format"Ĭonst REST_DOWNLOAD_URL = REST_URL + '/token' "Excel can not open file 'file.xlsx' because the file format or file extension is not valid. I am available at any questions you might have.I'm trying to download an xlsx file with reactJS but i'm receiving this message when i try to open my file after download: Now that we have installed our dependencies, it’s time to run our app. Now we need to install the dependencies, to do this, go to the file location and run the below command: npm install json2xls. So after much R&D and many ways, this is one technique I have come up to use and it's working successfully in the production. So, to do this let’s create a file convert.js and paste the below code: convert.js. And my total website is using AJAX (JS+ WebServices and no updatepanel), in this case I cannot use any server controls because that will post back my full page and I do not want that to happen. I had the requirement in my project to get the data from database and create an Excel file and insert the data and download the file to user machine. This technique is light weight on the page. You can use AJAX ( Scriptmanager + Updatepanel) to download the file from server, but you have to post back the page. (type, " scrHandlerStartUp", GetStartUpScript(), true) (type, " scrScripts", " Common/Loaders/LoadScripts.aspx") ExcelFile.xls) when you submit an iframe.Ĭopy Code protected void Page_Load( object sender, EventArgs e) Then create form tag with one input control to pass filename (e.g. It will create an iframe dynamically and which has width, height and border as 0.

Create FileHandler.js file to do the main work.

Public static string MIMETypeDescription(Enum mimeType)įieldInfo fi = mimeType.GetType().GetField(mimeType.ToString())
