attribute+Formula (col)

컬럼에 설정해 셀별로 배경색(Color), 편집 가능 여부(CanEdit), 텍스트 색(TextColor) 등의 속성을 조건에 따라 다르게 적용할 때 이용합니다.
CanFormula1로 설정되어야 동작하며, CalcOrder열이름+속성명 형식으로 정의해야 합니다.
컬럼에 설정하지만 셀 단위로 실행되므로, 도움말 properties → Cell 카테고리에 정의된 셀 단위 속성만 속성명Formula 형식으로 사용할 수 있습니다.

Type

mixed( function | string )

Options

Value Description
string 컬럼명·예약어를 식에 직접 사용한 수식 문자열 (예: "Value > 100 ? '#FF0000' : '#FFFFAA'")
function 계산 결과를 return하는 함수 (return 값이 없으면 반영 안 됨)
첫 번째 인자로 fr 객체가 자동 전달됨

Parameters

function 형식 — 함수 인자 fr의 속성

Name Type Description
Sheet object 시트 객체
Row object 행 객체
Col string Formula 설정한 컬럼명
Attr string Formula가 적용되는 열이름+속성명 (예: yearSumColor, rateCanEdit)
Value mixed Formula 설정한 컬럼의 셀 값

string 형식 — 식 내 예약어

Name Type Description
Sheet object 시트 객체
Row object 행 객체
Col string Formula 설정한 컬럼명
Attr string Formula가 적용되는 열이름+속성명 (예: yearSumColor, rateCanEdit)
Value mixed Formula 설정한 컬럼의 셀 값
컬럼명 mixed 컬럼명을 직접 사용 시 해당 셀의 값 (예: yearSum > 100)

주의 사항

Example

options.Def.Row = {
    CanFormula: 1,
    // col attr+Formula의 CalcOrder는 "열이름+속성명" 형식, 항목 사이에 공백 없이
    CalcOrder: "yearSumColor,rateCanEdit"
};

options.Cols = [
    {Type: "Bool", Name: "CHK"},

    // string 형식 — Value 예약어로 자신의 셀 값 참조
    {Type: "Int", Name: "yearSum",
        ColorFormula: "Value > 100 ? '#FF0000' : '#FFFFAA'"
    },

    // function 형식 — fr 인자로 행 데이터 접근
    {Type: "Float", Name: "rate",
        CanEditFormula: function(fr) {
            return fr.Row["CHK"] == 1 && fr.Row["yearSum"] > 150;
        }
    }
];

Try it

Read More

Since

product version desc
core 8.0.0.0 기능 추가