1

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.

Community
  • 1
  • 1
Homer
  • 7,594
  • 14
  • 69
  • 109
  • What formatting? What do you mean by that? – Jeff Mercado Oct 08 '12 at 16:23
  • CSS formatting, I guess I need a way to convert the computed style to inline. – Homer Oct 08 '12 at 16:25
  • This doens't really have anything to do with knockout. You are looking for a way to export html with styling (I don't think this is possible). That the html was generated by knockout is irrelevant. – Kyeotic Oct 08 '12 at 21:56
  • i know it's not strictly Knockout related, but i though it might help to include the library used to generate the HTML. I guess I could have included jQuery too. I almost have a solution now using [this inline css plugin](https://github.com/mvhenten/jQuery-inline-css). – Homer Oct 08 '12 at 22:03
  • Try http://excelbuilderjs.com/ (yeah, I built it). If you need a hand with it I can assist. We're using it at the company I work for with some pretty outstanding results. – Stephen Oct 09 '12 at 21:53
  • @Stephen I'll check it out. Why not submit it as an answer? – Homer Oct 10 '12 at 03:18
  • Well, it's likely not 100% what you're looking for as it requires a bit of extra instructions to get things the way you want. But, I'll submit an answer anyway with a bit more info.. – Stephen Oct 10 '12 at 04:40

1 Answers1

1

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 (i.e. $#,##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.

Stephen
  • 5,362
  • 1
  • 22
  • 33