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
Scotland Elenora Lesch 1947-03-10 West Martaburgh
Wales Amira Jacobs 2006-02-22 Schuylerberg
Scotland Maximillian Medhurst 2017-08-15 West Georgettechester
Wales Barton Kiehn 2009-06-20 South Gordon
Northern Ireland Adrian Schoen 1970-01-29 Stoneton
Northern Ireland Hardy McDermott 1945-05-18 West Luigi
England Alta Zulauf 2014-07-16 Hallechester
Northern Ireland Danyka Kuphal 1990-04-26 Andersonview
Scotland Allison Ankunding 1967-07-20 Gislasonside
Northern Ireland Dominic Hickle 1990-05-31 Funkport
England Alanna Funk 2007-01-22 South Nelson
Scotland Neoma Zulauf 1965-08-25 West Brandynfort
England Katelyn Becker 2025-05-02 Velvaborough
Scotland Francis Rempel 1972-12-21 Timmyport
Wales Geoffrey Botsford 1980-02-14 Mekhiland
England Alexzander Labadie 1993-01-13 New Timothy
Wales Agustina Runte 1965-11-14 Port Aaliyahtown
Wales Catherine DuBuque 2014-01-21 Schmittstad
Wales Margaret Quitzon 2022-10-03 Travonville
Scotland Edmond Carroll 1965-10-05 Matildastad
Wales Barton Auer 2012-10-31 Trompburgh
Scotland Vicky Conn 1945-11-06 Nienowbury
Scotland Mack Marquardt 1997-04-02 Huelstown
Northern Ireland Gage Pacocha 1979-09-26 Gradyhaven
England Orpha Heller 2002-06-29 North Hannahbury
Northern Ireland Savanah Cassin 1955-07-28 South Vanceville
Northern Ireland Idell Russel 2011-02-06 South Kasandra
England Barton Mitchell 1954-11-14 New Vickie
England Zachariah Shanahan 1979-10-12 Rozellaside
Wales Delphia Leffler 1945-02-28 Cristinafurt
Scotland Cecelia Morissette 1952-07-11 Lake King
Northern Ireland Raleigh Rowe 2025-08-08 Port Terrancehaven
Wales Marlon Mueller 1965-10-09 Abigayleview
Scotland Patsy Kub 1966-03-20 Mohamedside
Wales Eleazar Smith 1957-10-13 Kubburgh
Northern Ireland Wilton Kihn 1995-12-05 West Coleman
Wales Bonita Bins 1911-06-20 North Anguschester
Wales Zachery Pollich 1969-06-22 Lake Jarenland
Northern Ireland Winfield Lynch 1916-02-24 Bartellville
Northern Ireland German Powlowski 1910-05-11 North Wilberstad
Scotland Karlie O'Kon 1950-04-26 South Zoie
Wales Stanford Hirthe 2020-06-04 Botsfordburgh
Northern Ireland Willie Larkin 1989-01-05 Schowalterchester
Northern Ireland Avis Reichel 1986-06-17 New Gertrudestad
Wales Tyshawn Jaskolski 1970-05-02 Mertzchester
Wales Lavonne Cronin 2007-11-23 Port Easton
Wales Manuel Johnson 1981-03-12 Morarshire
Northern Ireland Theresia Mosciski 1981-04-07 Port Enola
England Luther Feeney 1984-09-20 Port Morganborough
Northern Ireland Adah Rice 1965-05-07 Dibbertstad

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">Scotland</td>
      <td role="cell">Elenora</td>
      <td role="cell">Lesch</td>
      <td data-value="-719971200000" role="cell" class="epp-ar epp-s1">1947-03-10</td>
      <td role="cell">West Martaburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Amira</td>
      <td role="cell">Jacobs</td>
      <td data-value="1140566400000" role="cell" class="epp-ar epp-s1">2006-02-22</td>
      <td role="cell">Schuylerberg</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Maximillian</td>
      <td role="cell">Medhurst</td>
      <td data-value="1502755200000" role="cell" class="epp-ar epp-s1">2017-08-15</td>
      <td role="cell">West Georgettechester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Barton</td>
      <td role="cell">Kiehn</td>
      <td data-value="1245456000000" role="cell" class="epp-ar epp-s1">2009-06-20</td>
      <td role="cell">South Gordon</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Adrian</td>
      <td role="cell">Schoen</td>
      <td data-value="2419200000" role="cell" class="epp-ar epp-s1">1970-01-29</td>
      <td role="cell">Stoneton</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Hardy</td>
      <td role="cell">McDermott</td>
      <td data-value="-777081600000" role="cell" class="epp-ar epp-s1">1945-05-18</td>
      <td role="cell">West Luigi</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Alta</td>
      <td role="cell">Zulauf</td>
      <td data-value="1405468800000" role="cell" class="epp-ar epp-s1">2014-07-16</td>
      <td role="cell">Hallechester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Danyka</td>
      <td role="cell">Kuphal</td>
      <td data-value="641088000000" role="cell" class="epp-ar epp-s1">1990-04-26</td>
      <td role="cell">Andersonview</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Allison</td>
      <td role="cell">Ankunding</td>
      <td data-value="-77414400000" role="cell" class="epp-ar epp-s1">1967-07-20</td>
      <td role="cell">Gislasonside</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Dominic</td>
      <td role="cell">Hickle</td>
      <td data-value="644112000000" role="cell" class="epp-ar epp-s1">1990-05-31</td>
      <td role="cell">Funkport</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Alanna</td>
      <td role="cell">Funk</td>
      <td data-value="1169424000000" role="cell" class="epp-ar epp-s1">2007-01-22</td>
      <td role="cell">South Nelson</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Neoma</td>
      <td role="cell">Zulauf</td>
      <td data-value="-137376000000" role="cell" class="epp-ar epp-s1">1965-08-25</td>
      <td role="cell">West Brandynfort</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Katelyn</td>
      <td role="cell">Becker</td>
      <td data-value="1746144000000" role="cell" class="epp-ar epp-s1">2025-05-02</td>
      <td role="cell">Velvaborough</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Francis</td>
      <td role="cell">Rempel</td>
      <td data-value="93744000000" role="cell" class="epp-ar epp-s1">1972-12-21</td>
      <td role="cell">Timmyport</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Geoffrey</td>
      <td role="cell">Botsford</td>
      <td data-value="319334400000" role="cell" class="epp-ar epp-s1">1980-02-14</td>
      <td role="cell">Mekhiland</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Alexzander</td>
      <td role="cell">Labadie</td>
      <td data-value="726883200000" role="cell" class="epp-ar epp-s1">1993-01-13</td>
      <td role="cell">New Timothy</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Agustina</td>
      <td role="cell">Runte</td>
      <td data-value="-130377600000" role="cell" class="epp-ar epp-s1">1965-11-14</td>
      <td role="cell">Port Aaliyahtown</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Catherine</td>
      <td role="cell">DuBuque</td>
      <td data-value="1390262400000" role="cell" class="epp-ar epp-s1">2014-01-21</td>
      <td role="cell">Schmittstad</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Margaret</td>
      <td role="cell">Quitzon</td>
      <td data-value="1664755200000" role="cell" class="epp-ar epp-s1">2022-10-03</td>
      <td role="cell">Travonville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Edmond</td>
      <td role="cell">Carroll</td>
      <td data-value="-133833600000" role="cell" class="epp-ar epp-s1">1965-10-05</td>
      <td role="cell">Matildastad</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Barton</td>
      <td role="cell">Auer</td>
      <td data-value="1351641600000" role="cell" class="epp-ar epp-s1">2012-10-31</td>
      <td role="cell">Trompburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Vicky</td>
      <td role="cell">Conn</td>
      <td data-value="-762220800000" role="cell" class="epp-ar epp-s1">1945-11-06</td>
      <td role="cell">Nienowbury</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Mack</td>
      <td role="cell">Marquardt</td>
      <td data-value="859939200000" role="cell" class="epp-ar epp-s1">1997-04-02</td>
      <td role="cell">Huelstown</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Gage</td>
      <td role="cell">Pacocha</td>
      <td data-value="307152000000" role="cell" class="epp-ar epp-s1">1979-09-26</td>
      <td role="cell">Gradyhaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Orpha</td>
      <td role="cell">Heller</td>
      <td data-value="1025308800000" role="cell" class="epp-ar epp-s1">2002-06-29</td>
      <td role="cell">North Hannahbury</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Savanah</td>
      <td role="cell">Cassin</td>
      <td data-value="-455414400000" role="cell" class="epp-ar epp-s1">1955-07-28</td>
      <td role="cell">South Vanceville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Idell</td>
      <td role="cell">Russel</td>
      <td data-value="1296950400000" role="cell" class="epp-ar epp-s1">2011-02-06</td>
      <td role="cell">South Kasandra</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Barton</td>
      <td role="cell">Mitchell</td>
      <td data-value="-477532800000" role="cell" class="epp-ar epp-s1">1954-11-14</td>
      <td role="cell">New Vickie</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Zachariah</td>
      <td role="cell">Shanahan</td>
      <td data-value="308534400000" role="cell" class="epp-ar epp-s1">1979-10-12</td>
      <td role="cell">Rozellaside</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Delphia</td>
      <td role="cell">Leffler</td>
      <td data-value="-783907200000" role="cell" class="epp-ar epp-s1">1945-02-28</td>
      <td role="cell">Cristinafurt</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Cecelia</td>
      <td role="cell">Morissette</td>
      <td data-value="-551491200000" role="cell" class="epp-ar epp-s1">1952-07-11</td>
      <td role="cell">Lake King</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Raleigh</td>
      <td role="cell">Rowe</td>
      <td data-value="1754611200000" role="cell" class="epp-ar epp-s1">2025-08-08</td>
      <td role="cell">Port Terrancehaven</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Marlon</td>
      <td role="cell">Mueller</td>
      <td data-value="-133488000000" role="cell" class="epp-ar epp-s1">1965-10-09</td>
      <td role="cell">Abigayleview</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Patsy</td>
      <td role="cell">Kub</td>
      <td data-value="-119491200000" role="cell" class="epp-ar epp-s1">1966-03-20</td>
      <td role="cell">Mohamedside</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Eleazar</td>
      <td role="cell">Smith</td>
      <td data-value="-385603200000" role="cell" class="epp-ar epp-s1">1957-10-13</td>
      <td role="cell">Kubburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Wilton</td>
      <td role="cell">Kihn</td>
      <td data-value="818121600000" role="cell" class="epp-ar epp-s1">1995-12-05</td>
      <td role="cell">West Coleman</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Bonita</td>
      <td role="cell">Bins</td>
      <td data-value="-1847232000000" role="cell" class="epp-ar epp-s1">1911-06-20</td>
      <td role="cell">North Anguschester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Zachery</td>
      <td role="cell">Pollich</td>
      <td data-value="-16675200000" role="cell" class="epp-ar epp-s1">1969-06-22</td>
      <td role="cell">Lake Jarenland</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Winfield</td>
      <td role="cell">Lynch</td>
      <td data-value="-1699488000000" role="cell" class="epp-ar epp-s1">1916-02-24</td>
      <td role="cell">Bartellville</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">German</td>
      <td role="cell">Powlowski</td>
      <td data-value="-1882224000000" role="cell" class="epp-ar epp-s1">1910-05-11</td>
      <td role="cell">North Wilberstad</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Scotland</td>
      <td role="cell">Karlie</td>
      <td role="cell">O'Kon</td>
      <td data-value="-621216000000" role="cell" class="epp-ar epp-s1">1950-04-26</td>
      <td role="cell">South Zoie</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Stanford</td>
      <td role="cell">Hirthe</td>
      <td data-value="1591228800000" role="cell" class="epp-ar epp-s1">2020-06-04</td>
      <td role="cell">Botsfordburgh</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Willie</td>
      <td role="cell">Larkin</td>
      <td data-value="599961600000" role="cell" class="epp-ar epp-s1">1989-01-05</td>
      <td role="cell">Schowalterchester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Avis</td>
      <td role="cell">Reichel</td>
      <td data-value="519350400000" role="cell" class="epp-ar epp-s1">1986-06-17</td>
      <td role="cell">New Gertrudestad</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Tyshawn</td>
      <td role="cell">Jaskolski</td>
      <td data-value="10454400000" role="cell" class="epp-ar epp-s1">1970-05-02</td>
      <td role="cell">Mertzchester</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Lavonne</td>
      <td role="cell">Cronin</td>
      <td data-value="1195776000000" role="cell" class="epp-ar epp-s1">2007-11-23</td>
      <td role="cell">Port Easton</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Wales</td>
      <td role="cell">Manuel</td>
      <td role="cell">Johnson</td>
      <td data-value="353203200000" role="cell" class="epp-ar epp-s1">1981-03-12</td>
      <td role="cell">Morarshire</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Theresia</td>
      <td role="cell">Mosciski</td>
      <td data-value="355449600000" role="cell" class="epp-ar epp-s1">1981-04-07</td>
      <td role="cell">Port Enola</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">England</td>
      <td role="cell">Luther</td>
      <td role="cell">Feeney</td>
      <td data-value="464486400000" role="cell" class="epp-ar epp-s1">1984-09-20</td>
      <td role="cell">Port Morganborough</td>
    </tr>
    <tr role="row" scope="row">
      <td role="cell">Northern Ireland</td>
      <td role="cell">Adah</td>
      <td role="cell">Rice</td>
      <td data-value="-146880000000" role="cell" class="epp-ar epp-s1">1965-05-07</td>
      <td role="cell">Dibbertstad</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;
}