Friday, November 1, 2013

Generating Excel and formatting numbers

I often write HTML tables and pass them off as Excel documents. This is an easy way to automate creation of an Excel sheet and gives you formatting options. The one I can never remember is how to force numbers to be formatted as text cells - to keep long numbers like 143417623220 from showing in scientific notation like 1.43+E11.

So here's the trick. Set a stylesheet and use this to force your numeric cells to format properly.

.text{
  mso-number-format:"\@"; /* force text format for numbers */
}


No comments:

Post a Comment