js2excel icon indicating copy to clipboard operation
js2excel copied to clipboard

Add jsonSheets2excel function

Open stackola opened this issue 6 years ago • 1 comments

I added a function called jsonSheets2excel, which can take json and convert it to xls while having the option to supply multiple sheets.

Example usage:

import { jsonSheets2excel } from "js2excel";

let data = {
	userdata: [
		{
			userId: 1,
			userPhoneNumber: 1888888888,
			userAddress: "xxxx",
			date: "2013/09/10 09:10" // string
		},
		{
			userId: 2,
			userPhoneNumber: 1888888888,
			userAddress: "xxxx",
			date: new Date()
		},
		{
			userId: 3,
			userPhoneNumber: 1888888888,
			userAddress: "xxxx",
			date: new Date()
		}
	],
	usernames: [
		{
			id: 1,
			username: "Hans"
		},
		{
			id: 2,
			username: "Peter"
		},
		{
			id: 3,
			username: "Marc"
		}
	]
};

try {
	jsonSheets2excel({
		data,
		name: "user-info-data",
		formateDate: "yyyy/mm/dd"
	});
} catch (e) {
	console.error("export error");
}

stackola avatar Aug 10 '18 17:08 stackola

+1

ryanande avatar Sep 15 '20 15:09 ryanande