html-generator icon indicating copy to clipboard operation
html-generator copied to clipboard

Table generation exemple

Open DCON16 opened this issue 8 years ago • 1 comments

Is there any table generation sample code ?

DCON16 avatar Jul 12 '17 10:07 DCON16

         public  string GetHTMLstring() 
        {
            var html = new HtmlDocument();
            
            html.AddHead();
            html.AddBody();
            
            var head = html.Head;
            var body = html.Body;
            var table = new HtmlElement("table");
            var thead = new HtmlElement("thead");

            var tableItems = new HtmlElement("tr");
            tableItems.Add(Tag
                .Th                
                .WithInnerText("Item1"));
            tableItems.Add(Tag
                .Th
                .WithInnerText("Item2"));
            tableItems.Add(Tag
                .Th
                .WithInnerText("Item2"));

            thead.Add(tableItems);
            table.Add(thead);
            
            head.Add(Tag
                .Title
                .WithInnerText("Title"));

            body.Add(Tag
                .H1
                .WithInnerText("Hello"));
            body.Add(Tag
                .P
                .WithInnerText("Message"));
            
            body.Add(table);


            
            return html.ToString();
        
        
        }

visign3d avatar Dec 27 '20 19:12 visign3d