forked from sheetjs/docs.sheetjs.com
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			908 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			908 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import Head from 'next/head';
 | 
						|
import { read, utils } from 'xlsx';
 | 
						|
import base64 from "@/sheetjs.xlsx";
 | 
						|
 | 
						|
export default function Index({type, aoo}) { return ( <>
 | 
						|
  <Head>
 | 
						|
    <meta httpEquiv="Content-Type" content="text/html; charset=UTF-8" />
 | 
						|
    <title>{`SheetJS Next.JS ${type} Demo`}</title>
 | 
						|
  </Head>
 | 
						|
  <h3>{`SheetJS Next.JS ${type} Demo`}</h3>
 | 
						|
  <p>
 | 
						|
    This demo reads from <code>/sheetjs.xlsx</code><br/><br/>
 | 
						|
    It generates objects from the first sheet.<br/><br/>
 | 
						|
  </p>
 | 
						|
  <table><thead><tr key={0}><th>Name</th><th>Index</th></tr></thead><tbody>
 | 
						|
    {aoo.map((row, R) => ( <tr key={R+1}>
 | 
						|
      <td>{row.Name}</td>
 | 
						|
      <td>{row.Index}</td>
 | 
						|
    </tr>))}
 | 
						|
  </tbody></table>
 | 
						|
</> ); }
 | 
						|
 | 
						|
export async function getStaticProps() {
 | 
						|
  const wb = read(base64, {type: "base64"});
 | 
						|
  return {
 | 
						|
    props: {
 | 
						|
      type: "getStaticProps",
 | 
						|
      aoo: utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]),
 | 
						|
    },
 | 
						|
  }
 | 
						|
}
 |