मैं अपने आप को द्वारा समाधान पाया है:
स्रोत-कोड यहाँ पर एक नजर डालें। कृपया एक उदाहरण कोड ले:
ExcelAddress _formatRangeAddress = new ExcelAddress("B3:B10,D3:D10,F3:F10,H3:H10:J3:J10");
// fill WHITE color if previous cell or current cell is BLANK:
// B3 is the current cell because the range _formatRangeAddress starts from B3.
// OFFSET(B3,0,-1) returns the previous cell's value. It's excel function.
string _statement = "IF(OR(ISBLANK(OFFSET(B3,0,-1)),ISBLANK(B3)),1,0)";
var _cond4 = sheet.ConditionalFormatting.AddExpression(_formatRangeAddress);
_cond4.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
_cond4.Style.Fill.BackgroundColor.Color = Color.White;
_cond4.Formula = _statement;
// fill GREEN color if value of the current cell is greater than
// or equals to value of the previous cell
_statement = "IF(OFFSET(B3,0,-1)-B3<=0,1,0)";
var _cond1 = sheet.ConditionalFormatting.AddExpression(_formatRangeAddress);
_cond1.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
_cond1.Style.Fill.BackgroundColor.Color = Color.Green;
_cond1.Formula = _statement;
// fill RED color if value of the current cell is less than
// value of the previous cell
_statement = "IF(OFFSET(B3,0,-1)-B3>0,1,0)";
var _cond3 = sheet.ConditionalFormatting.AddExpression(_formatRangeAddress);
_cond3.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
_cond3.Style.Fill.BackgroundColor.Color = Color.Red;
_cond3.Formula = _statement;
उपरोक्त उदाहरण में,
_formatRangeAddress
रेंज है कि अभिव्यक्ति द्वारा सशर्त स्वरूपण के लिए लागू किया जाएगा है। इस रेंज में पहला सेल स्थिति सूत्र में उपयोग किया जाएगा। (बी 3)।
_statement
हालत गणना के लिए इस्तेमाल सूत्र है, इस स्ट्रिंग बराबर के चिह्न (=
) (एमएस एक्सेल से अंतर बिंदु) के साथ नहीं शुरू करता है, सेल जो अभिव्यक्ति बनाने के लिए प्रयोग किया जाता है प्रथम कक्ष है _formatRangeAddress
में। (बी 3)।
आशा है कि यह उन लोगों के लिए सहायक हो जो आवश्यक हैं। -Han-
क्या आप "युक्त" टेक्स्ट सशर्त स्वरूपण –
के लिए प्रदान कर सकते हैं यह एक्सेल फ़ंक्शन है। मुझे लगता है कि वे 'ISNUMBER' और' खोज 'funcions का उपयोग करते हैं।http://office.microsoft.com/en-001/excel-help/check-if-a-cell-contains-text-HP003056106.aspx – Han
मैं एक्सेल पर सीधे सशर्त स्वरूपण का उपयोग करना चाहता हूं लेकिन मुझे कोई स्पष्ट नहीं है कि ' आपकी अभिव्यक्ति पर वर्तमान '। आपने अभिव्यक्ति 'IF (AND (ISBLANK (OFFSET (B3,0, -1)), ISBLANK (B3)), 1,0) के रूप में उपयोग किया है, और, कोड टिप्पणी में आप कहते हैं' // सफेद रंग भरें यदि इनमें से एक पिछले सेल या वर्तमान सेल ब्लैंक है: '। 'वर्तमान' सेल का संदर्भ कहां है? मैं केवल 'बी 3' देखता हूं। – jotapdiez