报告ReportEngineBase修改语言资源文件,修改模板和报告输出功能。
This commit is contained in:
@@ -54,6 +54,9 @@ namespace XP.ReportEngine.Services
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定页眉页脚中的表达式 | Bind expressions in header/footer
|
||||
BindHeaderFooter(clonedTemplate, context);
|
||||
|
||||
_logger.Info("数据绑定完成 | Data binding completed");
|
||||
return clonedTemplate;
|
||||
}
|
||||
@@ -99,6 +102,62 @@ namespace XP.ReportEngine.Services
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Row 子元素递归绑定 | Recursively bind row child elements
|
||||
if (string.Equals(element.Type, "row", StringComparison.OrdinalIgnoreCase)
|
||||
&& element.Children != null)
|
||||
{
|
||||
foreach (var child in element.Children)
|
||||
{
|
||||
BindElement(child, context);
|
||||
// Column 子元素递归绑定 | Recursively bind column child elements
|
||||
if (string.Equals(child.Type, "column", StringComparison.OrdinalIgnoreCase)
|
||||
&& child.Children != null)
|
||||
{
|
||||
foreach (var subChild in child.Children)
|
||||
{
|
||||
BindElement(subChild, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定页眉页脚中的 ${} 表达式 | Bind ${} expressions in header/footer
|
||||
/// </summary>
|
||||
private void BindHeaderFooter(ReportTemplate template, ReportContext context)
|
||||
{
|
||||
if (template?.Document == null) return;
|
||||
|
||||
// 绑定页眉文本 | Bind header text
|
||||
if (template.Document.Header != null && template.Document.Header.Enabled)
|
||||
{
|
||||
BindStringList(template.Document.Header.Left, context);
|
||||
BindStringList(template.Document.Header.Right, context);
|
||||
}
|
||||
|
||||
// 绑定页脚文本 | Bind footer text
|
||||
if (template.Document.Footer != null && template.Document.Footer.Enabled)
|
||||
{
|
||||
BindStringList(template.Document.Footer.Left, context);
|
||||
BindStringList(template.Document.Footer.Right, context);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定字符串列表中的表达式 | Bind expressions in string list
|
||||
/// </summary>
|
||||
private void BindStringList(List<string> lines, ReportContext context)
|
||||
{
|
||||
if (lines == null) return;
|
||||
for (int i = 0; i < lines.Count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(lines[i]))
|
||||
{
|
||||
lines[i] = ResolveAllExpressions(lines[i], context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string ResolveAllExpressions(string input, ReportContext context)
|
||||
@@ -313,10 +372,10 @@ namespace XP.ReportEngine.Services
|
||||
|
||||
var format = _localizationService.CurrentLanguage switch
|
||||
{
|
||||
SupportedLanguage.ZhCN => "yyyy年MM月dd日",
|
||||
SupportedLanguage.ZhTW => "yyyy年MM月dd日",
|
||||
SupportedLanguage.EnUS => "MM/dd/yyyy",
|
||||
_ => "yyyy-MM-dd"
|
||||
SupportedLanguage.ZhCN => "yyyy年MM月dd日 HH:mm:ss",
|
||||
SupportedLanguage.ZhTW => "yyyy年MM月dd日 HH:mm:ss",
|
||||
SupportedLanguage.EnUS => "MM/dd/yyyy HH:mm:ss",
|
||||
_ => "yyyy-MM-dd HH:mm:ss"
|
||||
};
|
||||
|
||||
return dateTime.ToString(format);
|
||||
|
||||
Reference in New Issue
Block a user