Html export - export table html and css

Use the dropdowns to change table style and theme, then click the Reload button. This is the only roundtrip done back to EPPlus. Change the appearance of the table by checking/unchecking the checkboxes.

All CSS classes needed to style the table are exported from EPPlus and based on Excels table styles and themes. You can use the dev tools of your favorite browser to see how the classes are applied to the table.

The checkboxes below demonstrates that you can use the html/css from EPPlus with css/javascript from other frameworks

Country FirstName LastName BirthDate City
Wales Kaylie McClure 1941-01-04 Nadiamouth
England Ali Grant 1924-02-11 Hartmannshire
England Isaias Lowe 1977-04-10 Morarmouth
England Antonietta Stamm 2020-03-22 West Jaceymouth
Wales Cloyd Schiller 2025-10-10 Boehmmouth
Scotland Roslyn Wiegand 1984-11-22 Nitzschebury
Wales Alfred Hettinger 2017-03-21 New Curtmouth
Scotland Stephon Ward 1903-07-02 Brianburgh
Wales Cheyenne Pfannerstill 1964-08-27 Yvetteview
England Kolby Jaskolski 1976-01-29 South Reed
Wales Eduardo Anderson 1964-04-20 Guadalupeshire
Wales Wyman O'Conner 1991-09-16 West Letha
England Rasheed Gottlieb 1925-09-21 Konopelskiton
Northern Ireland Carmen Jaskolski 1930-01-13 New Ciceroville
Wales Golden Jacobs 2003-08-19 Floridaside
Northern Ireland Myron Hammes 1962-06-05 Lake Lafayette
Scotland Augustus Effertz 1996-06-07 North Camryn
Wales Tiara Abbott 1933-12-19 West Lessiemouth
Scotland Cassie Kohler 1957-03-02 Tillmanview
Wales Suzanne Kuhn 1996-02-10 Lavadaville
Wales Hassie Upton 1974-08-05 West Emeryfurt
Northern Ireland Eleonore Mohr 2004-07-08 North Arlieport
England Otho Marquardt 2017-08-20 Abdulport
England Marianna Dooley 1978-11-18 Isabelmouth
Wales Eli Hammes 1990-01-15 Martinefurt
Scotland Van Keeling 1925-10-20 West Melisafort
Northern Ireland Myrtle Wuckert 1940-07-09 North Makayla
England Merritt Homenick 1995-11-12 Shannonview
Northern Ireland Tatyana Littel 1923-07-06 Lonfurt
Wales Stuart Tromp 1998-06-26 Port Judgehaven
Scotland Roslyn Smith 1963-04-19 Nathanaelfort
Northern Ireland Pink Hermann 1923-07-03 Schadenberg
Northern Ireland Frida Walter 1958-09-02 Breitenbergton
England Isom Emmerich 1930-02-01 Markfurt
Scotland Fernando Schneider 1996-08-01 New Zoe
England Howell Hane 1964-04-20 Wardview
England Donny Stark 2006-08-27 East Bridgette
Scotland Brandon Ebert 1997-10-20 Jesusborough
England Ursula Ledner 1974-09-13 Beierland
England Jaycee Haley 2001-12-03 North Rickhaven
Scotland Abdiel Kuvalis 1985-01-06 Strackeberg
Scotland Jarrell Morar 2019-01-07 West Chayahaven
Northern Ireland Breanna Konopelski 1933-10-22 Gibsonstad
Northern Ireland Emery Collins 2017-10-27 Murraychester
Wales Wilson Balistreri 1942-01-24 South Dwight
Wales Priscilla Tremblay 1986-03-10 Vestastad
Northern Ireland Frederik Ratke 1959-09-07 Lynchbury
Wales Laila Weber 1987-10-01 Keeblerborough
Northern Ireland Lindsay McClure 1928-03-16 Gottliebmouth
Northern Ireland Lola Blick 1944-12-24 Kutchton

Some selected parts of the model class for this page

            
public void SetupSampleData(int theme, TableStyles? style = TableStyles.Dark1)
{
    // This method just fakes some data into a data table
    InitDataTable();

    using(var package = new ExcelPackage())
    {
        SetTheme(theme, package);

        var sheet = package.Workbook.Worksheets.Add("Html export sample 1");
        var tableRange = sheet.Cells["A1"].LoadFromDataTable(_dataTable, true, style);
        // set number format for the BirthDate column
        sheet.Cells[tableRange.Start.Row + 1, 4, tableRange.End.Row, 4].Style.Numberformat.Format = "yyyy-MM-dd";
        tableRange.AutoFitColumns();

        var table = sheet.Tables.GetFromRange(tableRange);

        // table properties
        table.ShowFirstColumn = this.ShowFirstColumn;
        table.ShowLastColumn = this.ShowLastColumn;
        table.ShowColumnStripes = this.ShowColumnStripes;
        table.ShowRowStripes = this.ShowRowsStripes;

        // Export Html and CSS
        var exporter = table.CreateHtmlExporter();
        exporter.Settings.Minify = false;
        Css = exporter.GetCssString();
        Html = exporter.GetHtmlString();
        WorkbookBytes = package.GetAsByteArray();
    }
}

private static void SetTheme(int theme, ExcelPackage package)
{
    if (theme > 0)
    {
        var fileInfo = default(FileInfo);
        switch (theme)
        {
            case 1:
                fileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"themes\\Ion.thmx"));
                break;
            case 2:
                fileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"themes\\Banded.thmx"));
                break;
            case 3:
                fileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"themes\\Parallax.thmx"));
                break;
            default:
                fileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"themes\\Ion.thmx"));
                break;
        }
        package.Workbook.ThemeManager.Load(fileInfo);
    }
}

public string Css { get; set; }

public string Html { get; set; }
            
        

Html as it was exported

        
 <table class="epplus-table ts-dark1 ts-dark1-header" role="table">
  <thead role="rowgroup">
    <tr role="row">
      <th data-datatype="string" class="epp-al" role="columnheader" scope="col">Country</th>
      <th data-datatype="string" class="epp-al" role="columnheader" scope="col">FirstName</th>
      <th data-datatype="string" class="epp-al" role="columnheader" scope="col">LastName</th>
      <th data-datatype="datetime" class="epp-al" role="columnheader" scope="col">BirthDate</th>
      <th data-datatype="string" class="epp-al" role="columnheader" scope="col">City</th>
    </tr>
  </thead>
  <tbody role="rowgroup">
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Kaylie</td>
      <td role="cell">McClure</td>
      <td data-value="-914889600000" role="cell" class="epp-ar">1941-01-04</td>
      <td role="cell">Nadiamouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Ali</td>
      <td role="cell">Grant</td>
      <td data-value="-1448150400000" role="cell" class="epp-ar">1924-02-11</td>
      <td role="cell">Hartmannshire</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Isaias</td>
      <td role="cell">Lowe</td>
      <td data-value="229478400000" role="cell" class="epp-ar">1977-04-10</td>
      <td role="cell">Morarmouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Antonietta</td>
      <td role="cell">Stamm</td>
      <td data-value="1584835200000" role="cell" class="epp-ar">2020-03-22</td>
      <td role="cell">West Jaceymouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Cloyd</td>
      <td role="cell">Schiller</td>
      <td data-value="1760054400000" role="cell" class="epp-ar">2025-10-10</td>
      <td role="cell">Boehmmouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Roslyn</td>
      <td role="cell">Wiegand</td>
      <td data-value="469929600000" role="cell" class="epp-ar">1984-11-22</td>
      <td role="cell">Nitzschebury</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Alfred</td>
      <td role="cell">Hettinger</td>
      <td data-value="1490054400000" role="cell" class="epp-ar">2017-03-21</td>
      <td role="cell">New Curtmouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Stephon</td>
      <td role="cell">Ward</td>
      <td data-value="-2098656000000" role="cell" class="epp-ar">1903-07-02</td>
      <td role="cell">Brianburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Cheyenne</td>
      <td role="cell">Pfannerstill</td>
      <td data-value="-168739200000" role="cell" class="epp-ar">1964-08-27</td>
      <td role="cell">Yvetteview</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Kolby</td>
      <td role="cell">Jaskolski</td>
      <td data-value="191721600000" role="cell" class="epp-ar">1976-01-29</td>
      <td role="cell">South Reed</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Eduardo</td>
      <td role="cell">Anderson</td>
      <td data-value="-179884800000" role="cell" class="epp-ar">1964-04-20</td>
      <td role="cell">Guadalupeshire</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Wyman</td>
      <td role="cell">O'Conner</td>
      <td data-value="684979200000" role="cell" class="epp-ar">1991-09-16</td>
      <td role="cell">West Letha</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Rasheed</td>
      <td role="cell">Gottlieb</td>
      <td data-value="-1397347200000" role="cell" class="epp-ar">1925-09-21</td>
      <td role="cell">Konopelskiton</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Carmen</td>
      <td role="cell">Jaskolski</td>
      <td data-value="-1261267200000" role="cell" class="epp-ar">1930-01-13</td>
      <td role="cell">New Ciceroville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Golden</td>
      <td role="cell">Jacobs</td>
      <td data-value="1061251200000" role="cell" class="epp-ar">2003-08-19</td>
      <td role="cell">Floridaside</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Myron</td>
      <td role="cell">Hammes</td>
      <td data-value="-239068800000" role="cell" class="epp-ar">1962-06-05</td>
      <td role="cell">Lake Lafayette</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Augustus</td>
      <td role="cell">Effertz</td>
      <td data-value="834105600000" role="cell" class="epp-ar">1996-06-07</td>
      <td role="cell">North Camryn</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Tiara</td>
      <td role="cell">Abbott</td>
      <td data-value="-1137196800000" role="cell" class="epp-ar">1933-12-19</td>
      <td role="cell">West Lessiemouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Cassie</td>
      <td role="cell">Kohler</td>
      <td data-value="-405043200000" role="cell" class="epp-ar">1957-03-02</td>
      <td role="cell">Tillmanview</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Suzanne</td>
      <td role="cell">Kuhn</td>
      <td data-value="823910400000" role="cell" class="epp-ar">1996-02-10</td>
      <td role="cell">Lavadaville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Hassie</td>
      <td role="cell">Upton</td>
      <td data-value="144892800000" role="cell" class="epp-ar">1974-08-05</td>
      <td role="cell">West Emeryfurt</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Eleonore</td>
      <td role="cell">Mohr</td>
      <td data-value="1089244800000" role="cell" class="epp-ar">2004-07-08</td>
      <td role="cell">North Arlieport</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Otho</td>
      <td role="cell">Marquardt</td>
      <td data-value="1503187200000" role="cell" class="epp-ar">2017-08-20</td>
      <td role="cell">Abdulport</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Marianna</td>
      <td role="cell">Dooley</td>
      <td data-value="280195200000" role="cell" class="epp-ar">1978-11-18</td>
      <td role="cell">Isabelmouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Eli</td>
      <td role="cell">Hammes</td>
      <td data-value="632361600000" role="cell" class="epp-ar">1990-01-15</td>
      <td role="cell">Martinefurt</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Van</td>
      <td role="cell">Keeling</td>
      <td data-value="-1394841600000" role="cell" class="epp-ar">1925-10-20</td>
      <td role="cell">West Melisafort</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Myrtle</td>
      <td role="cell">Wuckert</td>
      <td data-value="-930355200000" role="cell" class="epp-ar">1940-07-09</td>
      <td role="cell">North Makayla</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Merritt</td>
      <td role="cell">Homenick</td>
      <td data-value="816134400000" role="cell" class="epp-ar">1995-11-12</td>
      <td role="cell">Shannonview</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Tatyana</td>
      <td role="cell">Littel</td>
      <td data-value="-1467158400000" role="cell" class="epp-ar">1923-07-06</td>
      <td role="cell">Lonfurt</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Stuart</td>
      <td role="cell">Tromp</td>
      <td data-value="898819200000" role="cell" class="epp-ar">1998-06-26</td>
      <td role="cell">Port Judgehaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Roslyn</td>
      <td role="cell">Smith</td>
      <td data-value="-211593600000" role="cell" class="epp-ar">1963-04-19</td>
      <td role="cell">Nathanaelfort</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Pink</td>
      <td role="cell">Hermann</td>
      <td data-value="-1467417600000" role="cell" class="epp-ar">1923-07-03</td>
      <td role="cell">Schadenberg</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Frida</td>
      <td role="cell">Walter</td>
      <td data-value="-357609600000" role="cell" class="epp-ar">1958-09-02</td>
      <td role="cell">Breitenbergton</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Isom</td>
      <td role="cell">Emmerich</td>
      <td data-value="-1259625600000" role="cell" class="epp-ar">1930-02-01</td>
      <td role="cell">Markfurt</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Fernando</td>
      <td role="cell">Schneider</td>
      <td data-value="838857600000" role="cell" class="epp-ar">1996-08-01</td>
      <td role="cell">New Zoe</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Howell</td>
      <td role="cell">Hane</td>
      <td data-value="-179884800000" role="cell" class="epp-ar">1964-04-20</td>
      <td role="cell">Wardview</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Donny</td>
      <td role="cell">Stark</td>
      <td data-value="1156636800000" role="cell" class="epp-ar">2006-08-27</td>
      <td role="cell">East Bridgette</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Brandon</td>
      <td role="cell">Ebert</td>
      <td data-value="877305600000" role="cell" class="epp-ar">1997-10-20</td>
      <td role="cell">Jesusborough</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Ursula</td>
      <td role="cell">Ledner</td>
      <td data-value="148262400000" role="cell" class="epp-ar">1974-09-13</td>
      <td role="cell">Beierland</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Jaycee</td>
      <td role="cell">Haley</td>
      <td data-value="1007337600000" role="cell" class="epp-ar">2001-12-03</td>
      <td role="cell">North Rickhaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Abdiel</td>
      <td role="cell">Kuvalis</td>
      <td data-value="473817600000" role="cell" class="epp-ar">1985-01-06</td>
      <td role="cell">Strackeberg</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Jarrell</td>
      <td role="cell">Morar</td>
      <td data-value="1546819200000" role="cell" class="epp-ar">2019-01-07</td>
      <td role="cell">West Chayahaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Breanna</td>
      <td role="cell">Konopelski</td>
      <td data-value="-1142208000000" role="cell" class="epp-ar">1933-10-22</td>
      <td role="cell">Gibsonstad</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Emery</td>
      <td role="cell">Collins</td>
      <td data-value="1509062400000" role="cell" class="epp-ar">2017-10-27</td>
      <td role="cell">Murraychester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Wilson</td>
      <td role="cell">Balistreri</td>
      <td data-value="-881625600000" role="cell" class="epp-ar">1942-01-24</td>
      <td role="cell">South Dwight</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Priscilla</td>
      <td role="cell">Tremblay</td>
      <td data-value="510796800000" role="cell" class="epp-ar">1986-03-10</td>
      <td role="cell">Vestastad</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Frederik</td>
      <td role="cell">Ratke</td>
      <td data-value="-325641600000" role="cell" class="epp-ar">1959-09-07</td>
      <td role="cell">Lynchbury</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Laila</td>
      <td role="cell">Weber</td>
      <td data-value="560044800000" role="cell" class="epp-ar">1987-10-01</td>
      <td role="cell">Keeblerborough</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Lindsay</td>
      <td role="cell">McClure</td>
      <td data-value="-1318982400000" role="cell" class="epp-ar">1928-03-16</td>
      <td role="cell">Gottliebmouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Lola</td>
      <td role="cell">Blick</td>
      <td data-value="-789609600000" role="cell" class="epp-ar">1944-12-24</td>
      <td role="cell">Kutchton</td>
    </tr>
  </tbody>
</table>
            
        

EPPlus converts the table styling in Excel to a separate stylesheet.

        
 table.epplus-table{
  font-family:Calibri;
  font-size:11pt;
  border-spacing:0;
  border-collapse:collapse;
  word-wrap:break-word;
  white-space:nowrap;
}
.epp-hidden {
  display:none;
}
.epp-al {
  text-align:left;
}
.epp-ar {
  text-align:right;
}
.epp-dcw {
  width:64px;
}
.epp-drh {
  height:20px;
}
table.epplus-table.ts-dark1 a{
  color:#ffffff;
}
table.epplus-table.ts-dark1 td:nth-child(4){
  text-align:right;
}
table.epplus-table.ts-dark1{
  background-color:#737373;
  color:#ffffff;
}
table.epplus-table.ts-dark1 thead{
  background-color:#000000;
  color:#ffffff;
  font-weight:bolder;
  border-bottom:medium solid #ffffff;
}
table.epplus-table.ts-dark1 tfoot{
  background-color:#262626;
  color:#ffffff;
  font-weight:bolder;
  border-top:medium solid #ffffff;
}
table.epplus-table.ts-dark1-column-stripes tbody tr td:nth-child(odd){
  background-color:#404040;
}
table.epplus-table.ts-dark1-row-stripes tbody tr:nth-child(odd){
  background-color:#404040;
}
table.epplus-table.ts-dark1-last-column tbody tr td:last-child{
  background-color:#404040;
  color:#ffffff;
  font-weight:bolder;
  border-left:medium solid #ffffff;
}
table.epplus-table.ts-dark1-first-column tbody tr td:first-child{
  background-color:#404040;
  color:#ffffff;
  font-weight:bolder;
  border-right:medium solid #ffffff;
}