コード例 #1
0
        /// <summary>
        /// Converts a SheetData reference into
        /// an Html Table
        /// </summary>
        /// <param name="sheet">SheetData reference</param>
        /// <param name="firstRowAsHeaders">Specify that the first row are the headers</param>
        /// <returns>Html Table</returns>
        public string HtmlTable(SheetData sheet, bool firstRowAsHeaders = true)
        {
            StringBuilder   grid = new StringBuilder(@"<table class='grid-table'>");
            List <object[]> rows = sheet.GetData();

            if (firstRowAsHeaders)
            {
                string[] columns = rows.ElementAt(0)
                                   .Select(c => c.ToString())
                                   .ToArray();
                rows.RemoveAt(0);
                grid.Append(Headers(columns));
            }
            grid.Append(Body(rows))
            .Append(@"</table>");
            return(grid.ToString());
        }