("file");
if (!file) throw new Error("File is required!");
var wb = read(file.content);
return response.html( utils.sheet_to_html(wb.Sheets[wb.SheetNames[0]]));
}
public GET(request: Drash.Request, response: Drash.Response): void {
return response.html(`\
SheetJS Spreadsheet to HTML Conversion Service
SheetJS Spreadsheet Conversion Service
API
Send a POST request to http://localhost:3000/ with the file in the "file" body parameter:
$ curl -X POST -F"file=@test.xlsx" http://localhost:3000/
The response will be an HTML TABLE generated from the first worksheet.
Try it out!
`,
);
}
}
const server = new Drash.Server({
hostname: "",
port: 3000,
protocol: "http",
resources: [ ParseResource ],
});
server.run();
console.log(`Server running at ${server.address}.`);
```
2) Run the server:
```bash
deno run --allow-net SheetJSDrash.ts
```
3) Download the test file
4) Open http://localhost:3000/ in your browser.
Click "Choose File" and select `pres.numbers`. Then click "Submit"
The page should show the contents of the file as an HTML table.