DataTable: Add Subtitle
This commit is contained in:
@ -20,7 +20,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
FileName = filename;
|
FileName = filename;
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
ZipArchive = ZipFile.Open(FileName, ZipArchiveMode.Create);
|
ZipArchive = ZipFile.Open(FileName, ZipArchiveMode.Create);
|
||||||
_tables = new();
|
_tables = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
@ -101,7 +101,12 @@ namespace Elwig.Helpers.Export {
|
|||||||
<style:style style:name="header" style:family="table-cell" style:parent-style-name="default">
|
<style:style style:name="header" style:family="table-cell" style:parent-style-name="default">
|
||||||
<style:table-cell-properties style:text-align-source="fix" style:repeat-content="false"/>
|
<style:table-cell-properties style:text-align-source="fix" style:repeat-content="false"/>
|
||||||
<style:paragraph-properties fo:text-align="center"/>
|
<style:paragraph-properties fo:text-align="center"/>
|
||||||
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" fo:font-size="16pt"/>
|
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" fo:font-size="16pt"/>
|
||||||
|
</style:style>
|
||||||
|
<style:style style:name="subheader" style:family="table-cell" style:parent-style-name="default">
|
||||||
|
<style:table-cell-properties style:text-align-source="fix" style:repeat-content="false"/>
|
||||||
|
<style:paragraph-properties fo:text-align="center"/>
|
||||||
|
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
|
||||||
</style:style>
|
</style:style>
|
||||||
<style:style style:name="th" style:family="table-cell" style:parent-style-name="default">
|
<style:style style:name="th" style:family="table-cell" style:parent-style-name="default">
|
||||||
<style:table-cell-properties style:text-align-source="fix" style:repeat-content="false" style:vertical-align="middle"/>
|
<style:table-cell-properties style:text-align-source="fix" style:repeat-content="false" style:vertical-align="middle"/>
|
||||||
@ -198,6 +203,9 @@ namespace Elwig.Helpers.Export {
|
|||||||
FormatCell(table.FullName, colSpan: totalSpan, style: "header") +
|
FormatCell(table.FullName, colSpan: totalSpan, style: "header") +
|
||||||
$" </table:table-row>\r\n" +
|
$" </table:table-row>\r\n" +
|
||||||
$" <table:table-row>\r\n" +
|
$" <table:table-row>\r\n" +
|
||||||
|
FormatCell(table.Subtitle, colSpan: totalSpan, style: "subheader") +
|
||||||
|
$" </table:table-row>\r\n" +
|
||||||
|
$" <table:table-row>\r\n" +
|
||||||
$" <table:table-cell table:number-columns-repeated=\"{totalSpan}\"/>\r\n" +
|
$" <table:table-cell table:number-columns-repeated=\"{totalSpan}\"/>\r\n" +
|
||||||
$" </table:table-row>\r\n" +
|
$" </table:table-row>\r\n" +
|
||||||
$" <table:table-row>\r\n");
|
$" <table:table-row>\r\n");
|
||||||
@ -251,8 +259,8 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
protected static string FormatCell(object? data, int rowSpan = 1, int colSpan = 1, string? style = "default", bool isCovered = false, string?[]? units = null) {
|
protected static string FormatCell(object? data, int rowSpan = 1, int colSpan = 1, string? style = "default", bool isCovered = false, string?[]? units = null) {
|
||||||
if (data?.GetType().IsValueType == true && data.GetType().Name.StartsWith("ValueTuple"))
|
if (data?.GetType().IsValueType == true && data.GetType().Name.StartsWith("ValueTuple"))
|
||||||
return string.Join("", data.GetType().GetFields().Zip(units ?? Array.Empty<string?>())
|
return string.Join("", data.GetType().GetFields().Zip(units ?? [])
|
||||||
.Select(p => FormatCell(p.First.GetValue(data), rowSpan, colSpan, style, isCovered, new[] { p.Second }))
|
.Select(p => FormatCell(p.First.GetValue(data), rowSpan, colSpan, style, isCovered, [p.Second]))
|
||||||
);
|
);
|
||||||
|
|
||||||
var add = (style != null ? $" table:style-name=\"{style}\"" : "") + (rowSpan > 1 || colSpan > 1 ? $" table:number-rows-spanned=\"{rowSpan}\" table:number-columns-spanned=\"{colSpan}\"" : "");
|
var add = (style != null ? $" table:style-name=\"{style}\"" : "") + (rowSpan > 1 || colSpan > 1 ? $" table:number-rows-spanned=\"{rowSpan}\" table:number-columns-spanned=\"{colSpan}\"" : "");
|
||||||
|
@ -8,6 +8,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
|
public string? Subtitle { get; set; }
|
||||||
public IEnumerable<T> Rows { get; private set; }
|
public IEnumerable<T> Rows { get; private set; }
|
||||||
public int RowNum => Rows.Count();
|
public int RowNum => Rows.Count();
|
||||||
public int ColNum => ColumnNames.Count();
|
public int ColNum => ColumnNames.Count();
|
||||||
|
Reference in New Issue
Block a user