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
England Roma Turcotte 1932-01-29 West Rachelhaven
England Horacio Miller 1991-05-20 Keeblershire
England Crystal Becker 1965-05-17 Nitzschehaven
Wales Johnpaul Waters 1984-10-18 Kattiehaven
Northern Ireland Malvina Heidenreich 1987-09-01 Sipesville
Wales Elody Bartell 1965-03-20 Yundtborough
Scotland Arnoldo Stiedemann 2002-01-21 Francescofort
Wales Danny Bergstrom 1940-09-06 Jeradfurt
Scotland Hailee Watsica 1930-12-26 Langoshberg
Scotland Flavio Rath 1980-03-12 Rosenbaumton
Wales Dayana Torphy 1930-03-14 Port Morris
Wales Lillian Wolf 1986-02-05 Hegmannmouth
England Hoyt Watsica 1950-02-17 Aldachester
Wales Norval Wisozk 1965-01-14 South Winonafurt
Northern Ireland Dasia Bode 1958-09-11 New Joy
Northern Ireland Flavie Carroll 1914-11-19 Lake Zackery
Scotland Idella Lakin 2002-04-12 Thurmanville
Wales Ova Casper 1950-11-29 Wymantown
Northern Ireland Abigail Johnson 2013-01-07 North Anya
England Fae O'Reilly 2025-08-17 Port Josianne
England Jairo Dickens 1926-11-13 Langchester
Scotland Jeff Mayert 2011-06-18 North Marcelino
Scotland Georgianna Dickinson 1947-06-02 South Brookburgh
Scotland Andreanne Legros 2007-07-30 Brookchester
Wales Marlene Krajcik 1973-10-12 Uptontown
England Sandra Quigley 1997-03-25 Lake Evert
Northern Ireland Celestine Nicolas 1964-10-27 East Willy
England Madalyn Bins 1968-04-25 East Irvingside
Scotland Gerson Mertz 2025-04-04 Dinoland
Northern Ireland Kirk Wiza 1987-02-04 Purdytown
Scotland Orie Berge 1956-01-29 Port Savannaburgh
England Addison Hahn 1992-12-26 Rohantown
Northern Ireland Gerald Murray 1966-09-28 North Marianna
England Alan Buckridge 1957-08-26 New Coreneburgh
Northern Ireland Uriah Muller 1981-10-31 North Christa
England Shakira Grimes 1956-08-19 North Carmellamouth
England Evalyn Olson 2006-12-09 East Antonina
Wales Eino Gottlieb 2021-08-15 West Alisha
Scotland Chester Medhurst 1975-08-30 Townemouth
Northern Ireland Nolan Heathcote 1976-10-22 Tremblayport
Northern Ireland Yoshiko Barrows 1965-08-19 Fannychester
Wales Jed Huels 1996-05-10 Thompsonhaven
Northern Ireland Estel Prohaska 1992-07-03 Aylaville
England Taryn Kohler 1964-12-12 Justineland
England Christ Boehm 1959-08-12 Granvilleburgh
Northern Ireland Sarah Christiansen 1957-06-26 South Melodyville
Wales Delpha Bartoletti 1966-03-07 Twilachester
Wales Sheridan Osinski 2012-02-27 Jewessmouth
Wales Cleveland Hudson 1965-07-20 Shanahanfurt
Wales Moises Larkin 1927-06-21 Schaeferview

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">England</td>
      <td role="cell">Roma</td>
      <td role="cell">Turcotte</td>
      <td data-value="-1196812800000" role="cell" class="epp-ar epp-s1">1932-01-29</td>
      <td role="cell">West Rachelhaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Horacio</td>
      <td role="cell">Miller</td>
      <td data-value="674697600000" role="cell" class="epp-ar epp-s1">1991-05-20</td>
      <td role="cell">Keeblershire</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Crystal</td>
      <td role="cell">Becker</td>
      <td data-value="-146016000000" role="cell" class="epp-ar epp-s1">1965-05-17</td>
      <td role="cell">Nitzschehaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Johnpaul</td>
      <td role="cell">Waters</td>
      <td data-value="466905600000" role="cell" class="epp-ar epp-s1">1984-10-18</td>
      <td role="cell">Kattiehaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Malvina</td>
      <td role="cell">Heidenreich</td>
      <td data-value="557452800000" role="cell" class="epp-ar epp-s1">1987-09-01</td>
      <td role="cell">Sipesville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Elody</td>
      <td role="cell">Bartell</td>
      <td data-value="-151027200000" role="cell" class="epp-ar epp-s1">1965-03-20</td>
      <td role="cell">Yundtborough</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Arnoldo</td>
      <td role="cell">Stiedemann</td>
      <td data-value="1011571200000" role="cell" class="epp-ar epp-s1">2002-01-21</td>
      <td role="cell">Francescofort</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Danny</td>
      <td role="cell">Bergstrom</td>
      <td data-value="-925257600000" role="cell" class="epp-ar epp-s1">1940-09-06</td>
      <td role="cell">Jeradfurt</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Hailee</td>
      <td role="cell">Watsica</td>
      <td data-value="-1231286400000" role="cell" class="epp-ar epp-s1">1930-12-26</td>
      <td role="cell">Langoshberg</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Flavio</td>
      <td role="cell">Rath</td>
      <td data-value="321667200000" role="cell" class="epp-ar epp-s1">1980-03-12</td>
      <td role="cell">Rosenbaumton</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Dayana</td>
      <td role="cell">Torphy</td>
      <td data-value="-1256083200000" role="cell" class="epp-ar epp-s1">1930-03-14</td>
      <td role="cell">Port Morris</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Lillian</td>
      <td role="cell">Wolf</td>
      <td data-value="507945600000" role="cell" class="epp-ar epp-s1">1986-02-05</td>
      <td role="cell">Hegmannmouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Hoyt</td>
      <td role="cell">Watsica</td>
      <td data-value="-627091200000" role="cell" class="epp-ar epp-s1">1950-02-17</td>
      <td role="cell">Aldachester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Norval</td>
      <td role="cell">Wisozk</td>
      <td data-value="-156643200000" role="cell" class="epp-ar epp-s1">1965-01-14</td>
      <td role="cell">South Winonafurt</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Dasia</td>
      <td role="cell">Bode</td>
      <td data-value="-356832000000" role="cell" class="epp-ar epp-s1">1958-09-11</td>
      <td role="cell">New Joy</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Flavie</td>
      <td role="cell">Carroll</td>
      <td data-value="-1739404800000" role="cell" class="epp-ar epp-s1">1914-11-19</td>
      <td role="cell">Lake Zackery</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Idella</td>
      <td role="cell">Lakin</td>
      <td data-value="1018569600000" role="cell" class="epp-ar epp-s1">2002-04-12</td>
      <td role="cell">Thurmanville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Ova</td>
      <td role="cell">Casper</td>
      <td data-value="-602467200000" role="cell" class="epp-ar epp-s1">1950-11-29</td>
      <td role="cell">Wymantown</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Abigail</td>
      <td role="cell">Johnson</td>
      <td data-value="1357516800000" role="cell" class="epp-ar epp-s1">2013-01-07</td>
      <td role="cell">North Anya</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Fae</td>
      <td role="cell">O'Reilly</td>
      <td data-value="1755388800000" role="cell" class="epp-ar epp-s1">2025-08-17</td>
      <td role="cell">Port Josianne</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Jairo</td>
      <td role="cell">Dickens</td>
      <td data-value="-1361232000000" role="cell" class="epp-ar epp-s1">1926-11-13</td>
      <td role="cell">Langchester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Jeff</td>
      <td role="cell">Mayert</td>
      <td data-value="1308355200000" role="cell" class="epp-ar epp-s1">2011-06-18</td>
      <td role="cell">North Marcelino</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Georgianna</td>
      <td role="cell">Dickinson</td>
      <td data-value="-712713600000" role="cell" class="epp-ar epp-s1">1947-06-02</td>
      <td role="cell">South Brookburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Andreanne</td>
      <td role="cell">Legros</td>
      <td data-value="1185753600000" role="cell" class="epp-ar epp-s1">2007-07-30</td>
      <td role="cell">Brookchester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Marlene</td>
      <td role="cell">Krajcik</td>
      <td data-value="119232000000" role="cell" class="epp-ar epp-s1">1973-10-12</td>
      <td role="cell">Uptontown</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Sandra</td>
      <td role="cell">Quigley</td>
      <td data-value="859248000000" role="cell" class="epp-ar epp-s1">1997-03-25</td>
      <td role="cell">Lake Evert</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Celestine</td>
      <td role="cell">Nicolas</td>
      <td data-value="-163468800000" role="cell" class="epp-ar epp-s1">1964-10-27</td>
      <td role="cell">East Willy</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Madalyn</td>
      <td role="cell">Bins</td>
      <td data-value="-53222400000" role="cell" class="epp-ar epp-s1">1968-04-25</td>
      <td role="cell">East Irvingside</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Gerson</td>
      <td role="cell">Mertz</td>
      <td data-value="1743724800000" role="cell" class="epp-ar epp-s1">2025-04-04</td>
      <td role="cell">Dinoland</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Kirk</td>
      <td role="cell">Wiza</td>
      <td data-value="539395200000" role="cell" class="epp-ar epp-s1">1987-02-04</td>
      <td role="cell">Purdytown</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Orie</td>
      <td role="cell">Berge</td>
      <td data-value="-439430400000" role="cell" class="epp-ar epp-s1">1956-01-29</td>
      <td role="cell">Port Savannaburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Addison</td>
      <td role="cell">Hahn</td>
      <td data-value="725328000000" role="cell" class="epp-ar epp-s1">1992-12-26</td>
      <td role="cell">Rohantown</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Gerald</td>
      <td role="cell">Murray</td>
      <td data-value="-102902400000" role="cell" class="epp-ar epp-s1">1966-09-28</td>
      <td role="cell">North Marianna</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Alan</td>
      <td role="cell">Buckridge</td>
      <td data-value="-389750400000" role="cell" class="epp-ar epp-s1">1957-08-26</td>
      <td role="cell">New Coreneburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Uriah</td>
      <td role="cell">Muller</td>
      <td data-value="373334400000" role="cell" class="epp-ar epp-s1">1981-10-31</td>
      <td role="cell">North Christa</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Shakira</td>
      <td role="cell">Grimes</td>
      <td data-value="-421891200000" role="cell" class="epp-ar epp-s1">1956-08-19</td>
      <td role="cell">North Carmellamouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Evalyn</td>
      <td role="cell">Olson</td>
      <td data-value="1165622400000" role="cell" class="epp-ar epp-s1">2006-12-09</td>
      <td role="cell">East Antonina</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Eino</td>
      <td role="cell">Gottlieb</td>
      <td data-value="1628985600000" role="cell" class="epp-ar epp-s1">2021-08-15</td>
      <td role="cell">West Alisha</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Chester</td>
      <td role="cell">Medhurst</td>
      <td data-value="178588800000" role="cell" class="epp-ar epp-s1">1975-08-30</td>
      <td role="cell">Townemouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Nolan</td>
      <td role="cell">Heathcote</td>
      <td data-value="214790400000" role="cell" class="epp-ar epp-s1">1976-10-22</td>
      <td role="cell">Tremblayport</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Yoshiko</td>
      <td role="cell">Barrows</td>
      <td data-value="-137894400000" role="cell" class="epp-ar epp-s1">1965-08-19</td>
      <td role="cell">Fannychester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Jed</td>
      <td role="cell">Huels</td>
      <td data-value="831686400000" role="cell" class="epp-ar epp-s1">1996-05-10</td>
      <td role="cell">Thompsonhaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Estel</td>
      <td role="cell">Prohaska</td>
      <td data-value="710121600000" role="cell" class="epp-ar epp-s1">1992-07-03</td>
      <td role="cell">Aylaville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Taryn</td>
      <td role="cell">Kohler</td>
      <td data-value="-159494400000" role="cell" class="epp-ar epp-s1">1964-12-12</td>
      <td role="cell">Justineland</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Christ</td>
      <td role="cell">Boehm</td>
      <td data-value="-327888000000" role="cell" class="epp-ar epp-s1">1959-08-12</td>
      <td role="cell">Granvilleburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Sarah</td>
      <td role="cell">Christiansen</td>
      <td data-value="-395020800000" role="cell" class="epp-ar epp-s1">1957-06-26</td>
      <td role="cell">South Melodyville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Delpha</td>
      <td role="cell">Bartoletti</td>
      <td data-value="-120614400000" role="cell" class="epp-ar epp-s1">1966-03-07</td>
      <td role="cell">Twilachester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Sheridan</td>
      <td role="cell">Osinski</td>
      <td data-value="1330300800000" role="cell" class="epp-ar epp-s1">2012-02-27</td>
      <td role="cell">Jewessmouth</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Cleveland</td>
      <td role="cell">Hudson</td>
      <td data-value="-140486400000" role="cell" class="epp-ar epp-s1">1965-07-20</td>
      <td role="cell">Shanahanfurt</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Moises</td>
      <td role="cell">Larkin</td>
      <td data-value="-1342224000000" role="cell" class="epp-ar epp-s1">1927-06-21</td>
      <td role="cell">Schaeferview</td>
    </tr>
  </tbody>
</table>
            
        

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

        
 table.epplus-table{
  font-family:Aptos Narrow;
  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;
}
.epp-s1{
  white-space: nowrap;
  vertical-align:bottom;
}