0

I want to add Excel button below the html table, that gives an Excel sheet of the table. I am using C# behind it, but I want it do on client side just using jQuery or Javascript without using PHP or .NET... Not more.

I am searching for hours however I don't find any fix solution. There it said you can use activeX object and CSV however I don't see any running examples.

2 Answers 2

3

ActiveX will only run on Internet Explorer so your solution will be limited to that platform.

Without ActiveX or server side scripts there is no way to achieve this due to JavaScript security designs it is not allowed to create files or push in memory files to download streams.

Sign up to request clarification or add additional context in comments.

Comments

2

I would not recommend ActiveX or anything that tries to run code outside of the browser on the client system. ActiveX only works on IE not to mention the inherent security risks that brings about.

A possible method would be to use a server side script along with jquery to generate the file and return it without ever leaving the page your on. It looks good and you don't really have to jump through hoops to make it work nor will the user. (if you want an example of the jquery required to do this let me know).

For c# there is alot of tutorials on generating excel files from your data for example here.

The only reason I can think of that you would want to create the file locally is use of resources on your server. C# will be extremly efficient in generating that file not to mention there are a couple things you can do (dependant on the data) to negate any impact it has:

  • If the data changes are few and far between consider storing the generated file and directing to that the next time until the data has been changed.
  • Limit the data set it returns by way of a search criteria

There are plenty more optimization you could do but you get the idea.

1 Comment

oh well took too long to write up lmao

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.