Exporting HTML table data to Excel using C#
First off let's encapsulate what you are trying to do here.

Create a function that will format the DataTable.

private static DataTable FormatMovieReportTable(DataTable reportTable)
{
    foreach(DataColumn column in reportTable.Columns)
    {
        string colName = column.ColumnName;
        if(colName != "Movie Code")
        {
            foreach(DataRow row in reportTable.Rows)
            {
                string value = row[colName]
                if(value.Contains("%"))
                {
                    value = value.Replace("%", "");
                    if(value.Contains("."))
                    {
                        double number = 0.0;
                        double.TryParse(value, out number);
                        value = (number / 100).ToString("0.00##")
                    }
                    row[colName] = value;
                }
            }
        }
    }
    return reportTable;
}


Now create a function that will create the DataTable from the string values.

private DataTable JsonToTable&lt;T&gt;(string data, string html, string tableName)
{   
    DataTable output = null;
    IEnumerable&lt;T&gt; serializedData = data.JsonDeserialize&lt;T&gt;().AsEnumerable&lt;T&gt;();
    List&lt;SelectListItem&gt; colOrder = ParseColumnsToList(html);
    output = serializedData.ToDataTable&lt;T&gt;(colOrder);
    if(output!= null)
    {   
        output = FormatMovieReportTable(output);
        output.TableName = tableName;
    }
    return output
}


And now the excel output..

private void TableToExcel(DataTable table)
{
    ExcelPackage epackage = new ExcelPackage();
    // the ?? is just in case that the table name is null
    // "new sheet" is just some arbitrary default name
    ExcelWorksheet excel = epackage.Workbook.Worksheets.Add(table.TableName ?? "new sheet");
    excel.Cells["A1"].LoadFromDataTable(table, true);
}


From wherever you called the posted function you can separate the logic

private void ThisIsTheCallerMethod()
{
    string data, html, reportName;

    // Other things happen and variables are populated

    DataTable reportTable = JsonToTable&lt;SomeType&gt;(data, html, reportName);
    if(reportTable != null)
    {
        TableToExcel(reportTable);
    }

    // Create the MemoryStream, etc...
}