Use the condition numeric format on the web page

zhaozj2021-02-08  301

Use the condition numeric format on the web page

Wade TAIMICROSOFT CORPORATION Suitable for: Microsoft Excel 2000 Summary: This trick introduces how to customize numerical format when you post Microsoft Excel Workbooks or Worksheets to web pages. It shows how to use the NumberFormat property to specify the conditional font color shadow. In Microsoft® Excel, you can use NumberFormat properties to apply the condition value format in the cell in the spreadsheet. The condition value format uses a customized numeric format code, which shows how to display the value. You can specify up to three format code conditions. These conditions are separated by a semicolon. A common usage in the condition numerical format is to emphasize the numerical and numerical modes of different colors depending on the value of the cell. This type of simple condition is typically referred to as "traffic light" formatted. When you publish a spreadsheet or workbook to a web page, you can also use NumberFormat attributes to format the value displayed in the PivotList and spreadsheet components. Unlike Excel, you can specify up to four format code conditions; however, if you use the fourth condition, you cannot export data into Excel. To set the color for a portion of the format, specify the English name of the color in square brackets in this section. Even if you are using a non-English Excel version, you must also use the English name. You can also specify the color index by using the syntax color n, where n is an index. Color code must be the first item in this section and only support the first 8 colors in the palette. The following table lists these colors and equivalent color indexes.

Color Name Equivalent Color Index Name BlackColor 1WhiteColor 2Redcolor 3GreenColor 4BlueColor 5YellowColor 6MAGENTACOLOR 7CYANCOLOR 8 To set the numeric format, only when the value meets the conditions you specify, please write the condition in square brackets; Conditions by a comparative operation Composition with a value. You can choose from the comparison operators listed in the following table.

Operator DE SCRIP TION = equal to greater than <= less than or equal to> = greater than or equal to <> 不 不The value of less than or equal to 50 is formatted into a yellow font and has a number in the right side of the decimal point; formatting the numerical value of less than 400 as a green integer; formatting the value greater than or equal to 400 into MAGENTA integer.

SUB Formatcells ()

SET OINVSS = NUMFMT_20284_WEBCALC

Oinvss.Range ("b2: b6"). Numberformat = _

"[Red] [<10] # 0.00; [Yellow]" _

"[<= 50] # 0.0; [Green] [<400]" _

"## 0; [MAGENTA] [> = 400] ### 0"

End Sub -> Please note that for the PivotList component, any of the formatted conditions you use for the total will also be used for small and total rows and columns (when they are visible). For the PivotList field, the conditional format color will not be applied when the field is in the list of columns or rows. To see the code used

转载请注明原文地址:https://www.9cbs.com/read-1326.html

New Post(0)