-
Notifications
You must be signed in to change notification settings - Fork 1
/
S1Table.cs
44 lines (38 loc) · 1.55 KB
/
S1Table.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
namespace BookFx.Usage
{
using System.Linq;
using static BookFx.Make;
public static class S1Table
{
private const string TotalFormula = "=SUM(Data C)";
public static byte[] Create() =>
Col()
.Add(Head())
.Add(Col()
.Add(Data("00001", "First long name with auto fit", 1000, 1020, 1500, 1550))
.Add(Data("00002", "Second long name with auto fit", 1200, 1240, 1600, 1690))
.NameLocally("Data"))
.Add(Total())
.AutoSpan()
.Style(Style().DefaultBorder())
.SetPrintArea()
.ToSheet()
.ToBook()
.ToBytes();
private static Box Head() =>
Row()
.SizeCols(TrackSize.Fit, TrackSize.Fit, 10, 10, 10, 10)
.Add("Code", "Name", HeadPlanFact("Beginning of year"), HeadPlanFact("End of year"))
.Style(Style().Center().Middle().Bold());
private static Box HeadPlanFact(string title) => Col(title, Row("Plan", "Fact"));
private static Box Data(string code, string name, params decimal[] values) =>
Row()
.Add(code, name)
.Add(values.Select(value => Value(value, Style().Money())));
private static Box Total() =>
Row()
.Add(Value("Grand total").SpanCols(2))
.Add(Enumerable.Repeat(Value(TotalFormula, Style().Money()), 4))
.Style(Style().Bold());
}
}