开发者

mso-number-format for Accounting

开发者 https://www.devze.com 2023-02-22 08:21 出处:网络
So does anyone know if there is an mso-number-format to mimic the Accounting format in Excel (Negatives are put in parens, zeros are dashes, all have 2 decimals and everything gets a dollar sign waaaa

So does anyone know if there is an mso-number-format to mimic the Accounting format in Excel (Negatives are put in parens, zeros are dashes, all have 2 decimals and everything gets a dollar sign waaaay to the left)

I have an html table that i am opening in excel that i would Love to have this format.

I found the fo开发者_开发问答llowing one online, but it doens't seem to work:

mso-number-format:\#\,\#\#0\.00_\)\;\[Black\]\\(\#\,\#\#0\.00\\)

Thanks


This is the string that I return from C# that gives a true Accounting format in Excel:

"\"_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \\\" - \\\"??_-;_-@_-\""

Some important things to note when dealing with mso-number-format:

  • All custom formats must be surrounded in double quotes
  • Any double quotes 'inside' the custom format must be replaced by literal "escaped double quotes", for Excel to interpret later.

So, you want the actual markup to be outputted like this

"_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \" - \"??_-;_-@_-"

Hope this helps


MSO is pretty proprietary to Microsoft, and hopefully this stuff won't be supported in the future so that UI Devs like me don't have to un-do it....fingers crossed.

My first inclination would be to dynamically build the excel spreadsheet with a tool like PHPExcel so that you have 100% control over formatting, calculations, etc the way that Excel is looking for it. Certainly there are variations of this software for the respective technology you have at your disposal (.net, java, etc)

Absent that solution, there are wonderful JQuery plugins such as this However, I'm not entirely sure this would suffice when you pull the html natively into Excel--it might not fire.

Do you have back-end technology available? Something like a regex replacement could quickly solve the problem with no ill effects on Excel.

From Microsoft's own website, CSS can't format numbers.

0

精彩评论

暂无评论...
验证码 换一张
取 消