I have n Javascript float arrays.
My goal is to generate and download a Zip file, using JS only, containing n CSV files, one per array.
I am aware of Javascript librairies like JSZip: http://stuk.github.io/jszip/ for generating zip files.
I also know how to generate and download a file on the fly using Blob and/or a library like FileSaver.js
However, I cannot figure out how to achieve the whole thing, client-side only.
Can anybody help me ?
Related
I need to convert a XML SpreadSheet to a native Excel file (XLSX), without using MSOffice.
In particular I need to make this conversion using Javascript.
I'm searching for in "StackOverflow" web page and also in google and other portals, but I don't find nothing about it.
The XML SpreadSheet sample file is like this:
enter image description here
On the other hand, I've discovered the "excelcnv.exe" command for conversion between formats, included in MSOffice Excel installation, but just I got to convert from XLS to XLSX, but not from XML SpreadSheet to XLSX...In fact I haven't found any documentation about this "excelcnv.exe" command so I don't know if it is possible this conversion.
Also I've found about some javascript libraries like oxml.js or XLSX but I think this libraries allow create a native excel file from scratch, not convert from input files in XML SpreadSheet format.
Maybe anybody could know how do this using javascript or some javascript library.
Any help will be very welcome :)
Thanks in advance,
You need to change the file extension. From xml to xls.
Then excelcnv will convert correctly.
excelcnv.exe -oice <INPUT> <OUPUT>
I want to make a zip file in JavaScript with "store" level compression, i.e. no compression, without having to download a whole library like JSzip because most of the functionality isn't needed. Is there a good way to do that?
The zip file format is relatively straightforward. You can implement your own zip file creation routines that only produce stored entries. You can find the zip file format documented here.
My answer is generate the zip file on the server and let users download it.
How do I parse zip file string. I looked for hours I couldn't find an easy to do it. All the examples I found didn't make much sense.
I use zipjs to handle zip files. A simple library that can handle reading and writing zip files.
BE MORE CLEAR NEXT TIME. I think this answer is what you need to hear.
A zip file can not be parsed with simple JavaScript. There is simply no native function that can ope ZIP files. There are certain libraries out there, but personally i have not found one that worked properly, and most use some kind of flash plugin to make it "work".
If you really want a zip file to be presented in Javascript, you will have to build its function with PHP. PHP can write to zip files, and read them: PHP ZIP. If you want to read the contents of a zip file, you would have to upload the file to the server (can be done with JS), then make the PHP return a JSON object with all the file_info of all the files inside the ZIP. And last but not least, JS should be able to acces another PHP page that retrieves a particular file, which can be done by reading the file and setting a mimetype before outputting its contents.
I have an array of files and I want to create a zip file out of this array.
Is there a way to create zip files using jQuery?
You can use the JSZip library mentioned by several people to create the zip. However, forcing a download from javascript and having it use a custom filename is a different matter.
HTML5 introduces a download attribute on <a>s. You could use it like this:
download
Which would force the download as "something.zip" in browsers supporting the download attribute. However, besides this, there is no way to do it from JavaScript.
Assuming I have some images, css and html concatenated in one file. Is it possible to use JS to display the html with images and css properly by ripping up the concatenated binary file somehow?
There are some ways to pack everything into a single file. But all of them are not crossbrowser. Everything depends on your goals.
Take a look at these formats:
MHTML http://en.wikipedia.org/wiki/MHTML
Webarchive http://en.wikipedia.org/wiki/Webarchive
Mozilla Archive Format http://en.wikipedia.org/wiki/Mozilla_Archive_Format
All of them are browser specific and even requires some extensions to be installed.
The easiest and the most supported way is to put all css and js files right into your html file. And use data:uri format to include your images into html.
Theoretically it is even possible to write a binary file reader in javascript.