简体   繁体   中英

Knockout - Export html table with formatting

How can I export a table generated using Knockout that will maintain the formatting?

I was using this solution ( How to export html table to excel using javascript ), but it does not include formatting.

As I mentioned in my comment, excelbuilderjs.com might work out for you. There are a couple of distinct downsides - one in that you can't simply turn an HTML table into an excel spreadsheet with colors and etc. It does require setup. But, in the case of where I work, we have a fairly standard color scheme and set of formatters that has been translated into a standalone set of instructions that is then included everywhere we need to construct a spreadsheet.

Based on a few simple examples of Knockout, you could probably just use the same data source to loop through and assign to EB - then just assign number formatting and date formatting as you would for an actual excel spreadsheet (ie $#,##0.00 for basic currency, m/d/yyyy for a basic date).

Side note - apparently some of my documentation didn't make it up. http://excelbuilderjs.com/cookbook/formatting.html is where you can get some basic info on formatting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM