///////////////////////////////////////////////////////////////////////////// #region code public Tuple<string, string> Build() { // ****** var tagList = new TagList { }; tagList.AddChild( new QuickTag( "h4" ) .SetValue( About ) ); // ****** var table = new Table( caption: "Money Flow", border: 0, id: "", attrAndStyles: "background : ivory" ); tagList.AddChild( table ); // ****** foreach( var item in AccountSummaryData.Create() ) { table.AddBodyRow( Content( item.Col1.ToString( "dd MMM yyyy" ), "width : 100px", "text-align : right" ), Content( item.Col2.ToString(), "width : 100px", "text-align : right" ), Content( item.Col3.ToString(), "width : 100px", "text-align : right" ), Content( item.Col4.ToString(), "width : 100px", "text-align : right" ), Content( item.Col5.ToString(), "width : 100px", "text-align : right" ), Content( item.Col6.ToString(), "width : 100px", "text-align : right" ), Content( item.Col7.ToString(), "width : 100px", "text-align : right", item.Col7 < 0 ? "color : red" : "" ) ); } // ****** return new Tuple<string, string>( Render( tagList ), nameof( TableWithFormatting2 ) ); }
///////////////////////////////////////////////////////////////////////////// #region code public Tuple<string, string> Build() { // ****** var tagList = new TagList { }; tagList.AddChild( new QuickTag( "h4" ) .SetValue( About ) ); // ****** var table = new Table( caption: "Checking Account", border: 0, id: "", attrAndStyles: "" ); tagList.AddChild( table ); // ****** foreach( var item in AccountSummaryData.Create() ) { table.AddBodyRow( item.Col1.ToString( "dd MMM yyyy" ), item.Col2.ToString(), item.Col3.ToString(), item.Col4.ToString(), item.Col5.ToString(), item.Col6.ToString(), item.Col7.ToString() ); } // ****** return new Tuple<string, string>( Render( tagList ), nameof( TableWithData ) ); }
///////////////////////////////////////////////////////////////////////////// #region code public Tuple<string, string> Build() { // ****** var tagList = new TagList { }; tagList.AddChild( new QuickTag( "h4" ) .SetValue( About ) ); // ****** var table = new Table(); tagList.AddChild( table ); table.AddAttributesAndStyles( "table-layout: fixed", "border-collapse: collapse", "border: 1px solid black", "margin: 0px", "padding : 0", "background : ivory" ); table.AddHeaderRow( Content( "", "colspan = 4" ), Content( $"4 month moving average", "colspan = 3" ) ) .AddHeaderRow( "Ending Date", "In", "Out", "Diff", "Moving Avg In", "Moving Avg Out", "Moving Avg Diff" ); table.AddStyleBlock( StyleBlockAddAs.Class, "td, th", "border : 1px solid black" ); table.AddBodyStyles(); // // yet another way to set body styles; a StylesFunc allows the interception of columns as they are // added, parameters are the column number being added and the StylesDictionary that represents that // column, return an IEnumerable<string> of styles to merge, or manipulate the styles dictionary // itself // // breaking out the StyleFunction on it's own makes this look a lot less messy and more readable than // inserting the lambda directly into SetDefaultBodyStyles() - at least for the sake of an example // StylesFunc sf = ( col, sd ) => col > 3 ? Styles( "font-style : italic " ) : null; table.SetDefaultBodyStyles( sf, 7, "width : 100px", "text-align : right" ); // ****** foreach( var item in AccountSummaryData.Create() ) { table.AddBodyRow( item.Col1.ToString( "dd MMM yyyy" ), item.Col2.ToString(), item.Col3.ToString(), item.Col4.ToString(), item.Col5.ToString(), item.Col6.ToString(), Content( item.Col7.ToString(), item.Col7 < 0 ? "color : red" : null ) ); } // ****** return new Tuple<string, string>( Render( tagList ), nameof( TableWithFormatting3 ) ); }
public void TestColumnNumber_1() { _table.AddBodyRow("a"); Assert.Equal(1, _table.ColumnNumber); }
/// <summary> /// 添加实体 /// </summary> private void AddEntity <T>(T entity, IEnumerable <string> propertyNames) where T : class { var values = GetPropertyValues(entity, propertyNames); Table.AddBodyRow(values.ToArray()); }