I want to have this  ,
   but instead have this
,
   but instead have this  .
   Please note, when I change VerticalAlign.Middle to VerticalAlign.Top it actually works as expected.
   Please see below code that I am trying:
.
   Please note, when I change VerticalAlign.Middle to VerticalAlign.Top it actually works as expected.
   Please see below code that I am trying:
   // I assume that table table is already created and well-defined  
   // Create a new row
    TableRow tRow = new TableRow();
    tRow.HorizontalAlign = HorizontalAlign.Center;
    // add the row to the table
    table.Rows.Add(tRow);
    // Create a new cell
    TableCell tCell = new TableCell();
    tCell.VerticalAlign = VerticalAlign.Middle; // Want to get it in the middle of two merged rows
    tCell.RowSpan = 2;
    tCell.Text = "England";
    tCell.Font.Bold = true;
    tRow.Cells.Add(tCell);
    // Create new cell
    tCell = new TableCell();
    tCell.Text = "2010";
    tCell.Font.Bold = true;
    tRow.Cells.Add(tCell);
    // Create new row
    tRow = new TableRow();
    // add the row to the table
    table.Rows.Add(tRow);
    // Create new cell
    tCell = new TableCell();
    tCell.Text = "2011";
    tCell.Font.Bold = true;
    tRow.Cells.Add(tCell);
Update: Please see extra code below. I don't have html code as such, but I looked at sw.ToString() and formatting looks right but still excel file does not seem to be rightly formatted. My browser is IE but I think it does not matter. I tried tCell.CssClass = "className"; result is the same.
public static void Comparison_Report(string fileName)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/ms-excel";
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
// Create a table to contain the grid
Table table = new Table();
///----- Original code goes here----
// render the table into the htmlwriter
table.RenderControl(htw);
// render the htmlwriter into the response  
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
}
 
     
     
     
    