internal void SetValueAndFormat(ICell cell, int?value, ConditionalStyle condStyle = ConditionalStyle.None) { if (value.HasValue) { cell.SetCellValue(value.Value); } cell.CellStyle = _cellStyleLib.Get(condStyle == ConditionalStyle.None ? CustomCellStyle.Default : CustomCellStyle.Note); }
internal void SetValueAndFormat(ICell cell, double?value, ConditionalStyle condStyle = ConditionalStyle.None) { if (value.HasValue) { cell.SetCellValue(value.Value); } cell.CellStyle = _cellStyleLib.Get(CustomCellStyle.Double, condStyle); }
private void ApplyConditionalStyle(ConditionalStyle condStyle, ICellStyle cellStyle) { switch (condStyle) { case (ConditionalStyle.Note): cellStyle.FillForegroundColor = IndexedColors.LightYellow.Index; cellStyle.BorderBottom = BorderStyle.Hair; //cellStyle.FillPattern = FillPattern.FineDots; cellStyle.FillPattern = FillPattern.SolidForeground; break; } }
public ICellStyle Get(CustomCellStyle rootCustomCellStyle, ConditionalStyle condStyle) { var s = rootCustomCellStyle.ToString(); if (condStyle != ConditionalStyle.None) { s = string.Format("{0}_{1}", s, condStyle); } var customCellStyle = CustomCellStyle.Default; Enum.TryParse <CustomCellStyle>(s, out customCellStyle); return(Get(customCellStyle)); }
internal void SetValueAndFormat(ICell cell, string value, ConditionalStyle condStyle = ConditionalStyle.None) { const int WRAPTHRESHOLD = 50; if (!string.IsNullOrEmpty(value)) { cell.SetCellValue(value); } var customCellStyle = CustomCellStyle.Default; if (!(value.Length <= WRAPTHRESHOLD && condStyle == ConditionalStyle.None)) { if (value.Length > WRAPTHRESHOLD) { customCellStyle = condStyle == ConditionalStyle.None ? CustomCellStyle.LongString : CustomCellStyle.LongString_Note; } else { customCellStyle = CustomCellStyle.Note; } } cell.CellStyle = _cellStyleLib.Get(customCellStyle); }