SetAxisPosition
设置数据条条件格式规则的轴位置。
语法
expression.SetAxisPosition(position);
expression - 表示 ApiDatabar 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| position | 必需 | XlDataBarAxisPosition | 数据条的轴位置设置。 |
返回值
此方法不返回任何数据。
示例
控制电子表格中数据条单元格内分割轴的放置位置。
// How do I choose whether the data bar axis sits at the midpoint or follows the data in a spreadsheet?
// Reposition the axis that separates positive and negative bars within cells in a spreadsheet.
let worksheet = Api.GetActiveSheet();
worksheet.GetRange("A1").SetValue("Sales Data");
worksheet.GetRange("A2").SetValue(100);
worksheet.GetRange("A3").SetValue(250);
worksheet.GetRange("A4").SetValue(150);
worksheet.GetRange("A5").SetValue(300);
worksheet.GetRange("A6").SetValue(75);
let dataRange = worksheet.GetRange("A2:A6");
let formatConditions = dataRange.GetFormatConditions();
let dataBar = formatConditions.AddDatabar();
worksheet.GetRange("C1").SetValue("Before:");
worksheet.GetRange("C2").SetValue(dataBar.GetAxisPosition());
dataBar.SetAxisPosition("xlDataBarAxisMidpoint");
worksheet.GetRange("C3").SetValue("After:");
worksheet.GetRange("C4").SetValue(dataBar.GetAxisPosition());