Vignesh Mohanraj
Vignesh Mohanraj

Reputation: 159

Extract and download HTML5 table as pdf,excel in Angular 4 CLI.?

I need to extract and download my HTML5 table as Excel sheet, pdf in Angular 4 CLI. How I can do that? Kindly help me to solve these issue.

Upvotes: 1

Views: 1962

Answers (1)

mbnx
mbnx

Reputation: 942

Both PDF and Excel are pretty complex file formats. Of course, exporting a table to such a format is not supported out of the box.

On server-side languages, there is a much better support for generating them, as more mature libraries are available. However, if you want to create PDFs from client-side Javascript, you can take a look at https://github.com/MrRio/jsPDF

To go the server-side way, you would implement some process like:

  • Serialize table data to JSON
  • Write an Angular service calling a server-side REST endpoint passing the serialized table data
  • Generate the PDF/Excel file on server-side, whatever technology you use
  • Move the generated file to some server-side folder accessible by the web-server for static file delivery
  • Return a download link as REST response.

Upvotes: 1

Related Questions