Export object as Excel File in Angular js - javascript

I am working on an angular js where I need to export an array of javascript objects. My code already has the provision to export is as a csv. To export as a csv the way is quite simple. I am building an object where each item is separated by a comma and each row by a new line and then using filewriter to write the file. For excel I came across an option like Alasql. Is there anyway I can do it? Is it possible to format the object in such a way so that we can directly use filewriter to save the object as an excel file?

There are 5 ways to export your data in excel.
read here for more information 5-Ways-to-export
And you can also use datatable plugin.
https://datatables.net/extensions/buttons/examples/initialisation/export.html

Related

React Export a Multiple Level Table to CSV File

I have a React table like this. Do we have anyway to export this table to CSV file and keep the same structure.
Yes, but how easy it is really depends on how the underlying state is being stored in your app.
The react-csv package allows you to pass it an array of data and add a Download button to your site, but you first need to arrange/collect the data into the right format for it.

How to import data from one svelte file to another

Sorry if I'm doing something wrong, I'm just starting with Svelte. I looked around on the web and couldn't find anything
I have a large hard coded data array made of objects that I want to keep in its own file while being able to access the data in app.svelte. I'm trying to keep my app.svelte as simple as possible. I tried export const data=[{data:"mydata"}] along with import {data} from "./data.svelte" but the export keyword means it expects the data to be sent over to data.svelte file, not the other way around. I really have no clue how to acheive this in Svelte. The data could also be json in a json file, as long as it is imported in my app.
Thank you for your help
.svelte files should be reserverd for components only, you can add your data in a regular javascript file instead
in data.js
export const data=[{data:"mydata"}]
in App.svelte
<script>
import { data } from './data.js'
</script>
This is possible with json files as well, but it will require an extra step as svelte does not by default understand json files. Depending on what bundler you use, you will have to add plugin, for Rollup this is https://www.npmjs.com/package/#rollup/plugin-json

How can I export image in Excel using Javascript?

One of my requirement is I want to export image and store inside excel using javascript.
I am using export excel using saveAs(blob, filename) and I am able to export javascript data into the excel but I could not able to export image? There is no any server side.
Any body has any idea over this
You can use xlsx library https://www.npmjs.com/package/xlsx
$("[id$=mybutton]").click(function(e) {
window.open('data:application/vnd.ms-excel,' + encodeURIComponent( $('div[id$=image]').html()));
e.preventDefault();
});
Demo https://jsfiddle.net/viethien/dfb3n2x1/11
There is a JS library to create excel. I haven't tried it though. https://github.com/stephenliberty/excel-builder.js However, it should be fairly trivial to loop through your JSON and create a CSV file, which will ultimately open in excel. That might work better depending on your needs.
But to be clear, when you say store an image, do you mean a link to an image, or a base64 text of an image? The latter would be huge and probably break excel in some way.
Other Resources:
https://www.grapecity.com/blogs/how-to-importexport-excel-files-using-javascript-and-spread-sheets

unable to download XLSX.Full.Min.JS

I am using below referenced code for Export to Excel:
How to export HTML tables to a single excel workbook with different sheets?
To execute this code we need the JS "xlsx.full.min" as mentioned below
<script>
src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.10.3/xlsx.full.min.js">
</script>
But I am getting a corrupt version of the js from given path and unable to find the correct format or correct version.
Please suggest the correct path where I can get the js in a right format.
Here is the Image of xlsx.full.min.js....

Trying to export data to excel file without jquery

Im trying to export the data i have into an excel file without jquery. I've read you can use javascript but most example have jquery. The reason i don't want to use jquery is that the project is build with react.
I already have the data from the database, so i don't need to bring it again.
I want to take that data and make it into an excel file.
little bit of the code below.
<li className='col-md-3 col-height col-middle'>
<span>{fromTime}</span> //contains data
</li>
Some example use table, is it possible to export from
<div>
<li>
<span>
Would appreciate any tips, example or anything
The most common way to export data into excel would be to covert it into a csv (comma seperated values) file which can then be opened in excel.
There are plenty of tutorials on how to do this, there are many different ways with a simple google. In your case doing this in php will likely be best because your getting it from a database.
SheetJS seems perfect for this.
To export your table as an excel file use the code in this link(along with SheetJS)
Just plug in your table element's id into export_table_to_excel

Categories

Resources