JS File Export

Source: Internet
Author: User

JS File Export

For js export files, you can use the ActiveXObject object in IE to save them. IE is something from Microsoft, so this is normal. But this is a headache for other browsers. After some online materials and some of my own attempts, I found FileSaver. js, which is very convenient to use. FileSaver. js is a type of HTML-based file storage, and natural HTML is also a trend.

The following shows how FileSaver. js supports some mainstream browsers.

Some browsers with poor support also provide a response solution. If necessary, go to the official address. With the help of blob objects, FileSaver. js loads Blob. js and FileSaver. js, and then directly calls to save the file. If the output content contains Chinese characters, add? To prevent Chinese garbled characters.

Var BB = self. Blob; saveAs (new BB ([? + Content] //? Prevent utf8 bom from Chinese garbled characters, {type: text/plain; charset = utf8}), demo.csv );
Output document content. Here I output a csv file and an excel form.

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.