本文整理汇总了C#中ISheet.GroupRow方法的典型用法代码示例。如果您正苦于以下问题:C# ISheet.GroupRow方法的具体用法?C# ISheet.GroupRow怎么用?C# ISheet.GroupRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISheet
的用法示例。
在下文中一共展示了ISheet.GroupRow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutNamesWithValidations
private void PutNamesWithValidations(ISheet ws, ICellStyle cs1, ICellStyle cs2, ICellStyle cs3, params string[][] names)
{
var rn0 = ws.PhysicalNumberOfRows;
var rn = rn0;
for (var i = 0; i < names.Length; ++i)
{
var rnc = rn++;
var r = ws.CreateRow(rnc);
if (1 < names[i].Length)
{
r.RowStyle = cs3;
var vh = ws.GetDataValidationHelper();
var vl = names[i].Skip(1).ToList();
vl.Sort();
var vd = vh.CreateValidation(
vh.CreateExplicitListConstraint(vl.ToArray()),
new CellRangeAddressList(rnc, rnc, 1, _excelVer.LastColumnIndex)
);
vd.ShowErrorBox = false;
vd.ShowPromptBox = true;
ws.AddValidationData(vd);
}
var c = r.CreateCell(0);
c.SetCellValue(names[i][0]);
if (0 == i)
{
c.CellStyle = cs1;
r.RowStyle = cs1;
}
else
{
c.CellStyle = cs2;
}
}
if (1 < names.Length) ws.GroupRow(rn0 + 1, rn - 1);
//ws.SetRowGroupCollapsed(rn0 + 1, true);
ws.AddMergedRegion(new CellRangeAddress(rn0, rn0, 0, _excelVer.LastColumnIndex));
}
示例2: SetValue
public override void SetValue(ISheet sheet, JToken token)
{
JArray data;
if (this.Each == "$root")
{
data = (JArray)token;
}
else
{
data = (JArray)token[Each];
}
var row = sheet.GetRow(RowIndex);
var grouprows = ExcelGroupRow.GetGroupRows(data, TreeCode);
for (int i = 0; i < data.Count; i++)
{
var item = data[i];
foreach (var cellTemplate in Cells)
{
var cell = row.GetCell(cellTemplate.ColIndex);
var val = item[cellTemplate.Bind];
cellTemplate.SetCellValue(cell, val);
}
if (i != data.Count - 1) {
row = sheet.CopyRow(row.RowNum, row.RowNum + 1);
}
}
var groups = grouprows.Values.OrderByDescending(o => o.TreeCode).ToList();
var b = JsonConvert.SerializeObject(groups);
foreach (var grouprow in groups)
{
sheet.GroupRow(grouprow.StartIndex + RowIndex+1, grouprow.EndIndex + RowIndex);
}
if (data.Count == 0) {
sheet.ShiftRows(row.RowNum+1, sheet.LastRowNum, -1);
}
}