import Head from 'next/head';
import { readFile, set_fs, utils } from 'xlsx';
import { join } from 'path';
import { cwd } from 'process';
export default function Index({type, html}) { return (
{`SheetJS Next.JS ${type} Demo`}
{`SheetJS Next.JS ${type} Demo`}
This demo reads from /sheetjs.xlsx
It generates HTML from the first sheet.
); }
export async function getServerSideProps() {
set_fs(await import("fs"));
const wb = readFile(join(cwd(), "sheetjs.xlsx"))
return {
props: {
type: "getServerSideProps",
html: utils.sheet_to_html(wb.Sheets[wb.SheetNames[0]]),
},
}
}