本帖最后由 jyjc 于 2021-2-24 11:54 编辑
自定义函数设置如下;
namespace Mysoft.Szjcpt.GcExcel.CustomFunctionX
{
public class MYDBRWFunctionX : CustomFunction
{
/// <summary>
/// 自定义函数
/// </summary>
public MYDBRWFunctionX()
: base("MYDBRW", FunctionValueType.Object, CommonFunctionX.CreateParameters())
{
}
public override object Evaluate(object[] arguments, ICalcContext context)
{
var cell = context.Worksheet.Cells[context.Row, context.Column];
//按属性设置样式
cell.Interior.Color = Color.FromArgb(240, 241, 244);
cell.Locked = true;
cell.Font.Size = 10.5;
cell.IndentLevel = 0;
cell.Borders.Color = Color.FromArgb(225, 227, 230);
cell.HorizontalAlignment = HorizontalAlignment.Right;
cell.Borders.LineStyle = BorderLineStyle.Thin;
//按style设置样式
cell.Style = context.Worksheet.Workbook.Styles["ReadOnlyStyle"];
return "";
}
}
}
表格使用格式:=MYDBRW("x_面积规划指标_产品",$B$1,$B$2,$A4,$B$3)
|