Using the PercentCellType for Numbers with Units

Posted by: pontius on 8 September 2017, 2:59 pm EST

  • Posted 8 September 2017, 2:59 pm EST


    I have to display numbers with engineering units like "50 mph" or "25 °C"  and would like to display them together in a cell.
    The PercentCellType already has the PercentSign property that I could easily use for this purpose by setting the PercentSign = " mph" for instance.

    Is there something to be said against this possibility?

    Or should I better write my own EditBaseCellType derived CustomCellType class for this purpose?


  • Replied 8 September 2017, 2:59 pm EST


    Using the precent cell type as you are considering could cause some issues. The displayed value is 100 times the stored value (i.e. 25% is 0.25). When putting values into the spreadsheet, you would have to divide the values by 100. When getting values out of the spreadsheet, you would have to multiply the values by 100. Using formulas inside the spreadsheet could get tricky. For example, suppose cells A1:B1 represent the lengths of the sides of a rectangle which is "2 ft" by "3 ft" and you want to find the area of the rectangle in "sqft". The normal formula for finding area (i.e. =A1*B1) would produce the wrong result (i.e. "2 ft" * "3 ft" = 0.02 * 0.03 = 0.0006 = "0.06 sqft").

  • Replied 8 September 2017, 2:59 pm EST

    Hi bobbyo,

    if that's all then I feel comfortable.

    I do not use any formulas. I just allow the user to edit data (without editing the engineering unit). Later on I save the data in a file or read data from a file where I have to take into account the factor of 100.

    Thanks and regards,

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels