Best way to represent the presentation format of cells in a grid?

I am creating a dynamic reporting feature for a client. They want to create new stored procedures and match new reports to them. We are using T-SQL and each cell in the grid / report can have its own formatting and / or functionality.

I'm looking for a format specification to identify the presentation, color, and legend for the data ... for example, I'm thinking of something like this:

{data} | {format}
123.56 | $ # ## 0.00

Results in ... $ 123.56

I'm looking for standard ways to represent a formatting field with color and conventions. Is there any other standard?

0


a source to share


1 answer


It all depends on what you are looking for. You have to ask yourself what types of formatting you want to apply. Here are some examples you can consider:

  • Inline formatting

    Do you want a cell that contains mixed formatting (for example, " 1234 .567" in bold, italic, and italic in one cell)?

  • output based on multiple columns

    Do you want to output the value in a cell based on multiple cells?

    Cell1="1234"
    Cell2="56"
    Cell3={Cell1}.{Cell2} 
    ---> which would output "1234.56"
    
          

If you don't need any of these things, then all you want to do is provide a consistent format for the entire cell. Let's split it into two formatting elements, transforms and visuals :

  • Formatting "1234.5678" to "1234.56" is a conversion. This must be done with code that knows how to interpret a value as a number, and how to convert that number into a character-digits text string.

  • Making a blue cell or text in red or bold are all visual transformations, which are just a set of attributes related to the display of data in a cell. We don't care about the type of data in the cell as we just need to put the pixels on the screen.



So the bottom line: everything about what you want. If you create HTML reports, HTML and CSS are very handy methods for describing the formatting of the visual effects of a cell, since you don't have to convert them twice.

As far as I know, there are only a few standards for coding visual effects and they are similar to SGML - TeX, HTML, PostScript, etc .; they all have "tags" (sometimes with "attributes") to change the display of the content in the tag.

This leaves us with transformational formatting. There were two general approaches to this. The first is procedural. You list a set of transformations you want to do to the data in order to turn it into text. Nowadays we often use replacement masks like in your example $#,##0.00

, or like in sprintf

%.2f

etc.

Again, just choose the formatting specifier that is the simplest in your environment. If you are coding a language that accepts a certain format, use it!

+1


a source







All Articles