diff --git a/ClosedXML.Report/Options/HeightRangeTag.cs b/ClosedXML.Report/Options/HeightRangeTag.cs new file mode 100644 index 0000000..e24459b --- /dev/null +++ b/ClosedXML.Report/Options/HeightRangeTag.cs @@ -0,0 +1,18 @@ +using System.Linq; +using ClosedXML.Report.Utils; + +namespace ClosedXML.Report.Options +{ + public class HeightRangeTag : RangeOptionTag + { + public int Height => Parameters.Any() ? Parameters.First().Key.AsInt() : 0; + + public override void Execute(ProcessingContext context) + { + var firstRow = context.Range.FirstRowUsed(); + var lastRow = context.Range.LastRowUsed(); + + Range.Worksheet.Rows(firstRow.WorksheetRow().RowNumber(), lastRow.WorksheetRow().RowNumber()).Height = Height; + } + } +} diff --git a/ClosedXML.Report/Options/HeightTag.cs b/ClosedXML.Report/Options/HeightTag.cs new file mode 100644 index 0000000..3b5c2a6 --- /dev/null +++ b/ClosedXML.Report/Options/HeightTag.cs @@ -0,0 +1,17 @@ +using System.Linq; +using ClosedXML.Report.Utils; + +namespace ClosedXML.Report.Options; + +public class HeightTag : OptionTag +{ + public int Height => Parameters.Any() ? Parameters.First().Key.AsInt() : 0; + + public override void Execute(ProcessingContext context) + { + var xlCell = Cell.GetXlCell(context.Range); + var cellRow = xlCell.WorksheetRow().RowNumber(); + + Range.Worksheet.Rows(cellRow, cellRow).Height = Height; + } +} diff --git a/ClosedXML.Report/RangeTemplate.cs b/ClosedXML.Report/RangeTemplate.cs index 99e0416..bdabddf 100644 --- a/ClosedXML.Report/RangeTemplate.cs +++ b/ClosedXML.Report/RangeTemplate.cs @@ -146,11 +146,11 @@ private static IEnumerable GetInnerRanges(IXLRange prng) public IReportBuffer Generate(object[] items) { _evaluator.AddVariable("items", items); + foreach (var v in _globalVariables) { _evaluator.AddVariable("@" + v.Key, v.Value); } - _rangeTags.Reset(); if (IsHorizontal) { @@ -160,6 +160,7 @@ public IReportBuffer Generate(object[] items) { VerticalTable(items, _evaluator); } + return _buff; } @@ -482,10 +483,16 @@ where TagExtensions.HasTag(value) tags = _tagsEvaluator.Parse(cell.GetString(), range, cell, out newValue); cell.Value = newValue; } - if (cell.Row > 1 && cell.Row == _rowCnt) - _rangeTags.AddRange(tags); - else - _tags.AddRange(tags); + + foreach (var optionTag in tags) + { + if (cell.Row > 1 && cell.Row == _rowCnt) + _rangeTags.Add(optionTag); + else if (optionTag is RangeOptionTag) + _rangeTags.Add(optionTag); + else + _tags.Add(optionTag); + } } _rangeOption = _rangeTags.GetAll().Union(_tags.GetAll()).FirstOrDefault(); diff --git a/ClosedXML.Report/XLTemplate.cs b/ClosedXML.Report/XLTemplate.cs index 3af8b40..04283e3 100644 --- a/ClosedXML.Report/XLTemplate.cs +++ b/ClosedXML.Report/XLTemplate.cs @@ -58,6 +58,8 @@ static XLTemplate() TagsRegister.Add("Hide", 0); TagsRegister.Add("PageOptions", 0); TagsRegister.Add("Protected", 0); + TagsRegister.Add("Height", 0); + TagsRegister.Add("HeightRange", 0); } public XLTemplate(string fileName) : this(new XLWorkbook(fileName))