Inquiridor
Merge entre celulas no excel

Pergunta
-
Galera, preciso fazer uns "merges" em um arquivo excel mas esta danco uns erros estranhos, o código que utilizo é:
protected void btnGenerateExcell_Click(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=Report.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); foreach (RepeaterItem item in rptData.Items) { //GridView gvDt = (GridView)item.FindControl("gvdata"); Label lblService = (Label)item.FindControl("lblService"); GridView gvDt = new GridView(); gvDt.DataSource = dataBase.prc_vaViewVesselPositionReport(Convert.ToInt16(Session["SlinID"]), Convert.ToInt16(ddlService.SelectedValue)); gvDt.DataBind(); //gvDt.HeaderRow.Cells[0].Visible = false; //lblService.ForeColor = System.Drawing.Color.Black; gvDt.ShowHeader = true; //Altere a linha de cabeçalho de volta para a cor branca gvDt.HeaderRow.Style.Add("background-color", "#000000"); gvDt.HeaderRow.Cells[0].Text = "NAVIO"; gvDt.HeaderRow.Cells[0].RowSpan = 2; gvDt.HeaderRow.Cells[1].Text = "VIAGEM"; gvDt.HeaderRow.Cells[1].RowSpan = 2; gvDt.HeaderRow.Cells[2].Text = "ETA"; gvDt.HeaderRow.Cells[2].RowSpan = 2; gvDt.HeaderRow.Cells[3].Text = "DRAFT"; gvDt.HeaderRow.Cells[3].RowSpan = 1; gvDt.HeaderRow.Cells[4].Text = "MDG / OOG"; gvDt.HeaderRow.Cells[4].RowSpan = 1; gvDt.HeaderRow.Cells[5].Text = "CARGA / SD"; gvDt.HeaderRow.Cells[5].RowSpan = 1; gvDt.HeaderRow.Cells[6].Text = "SAÍDA"; gvDt.HeaderRow.Cells[6].RowSpan = 2; gvDt.HeaderRow.Cells[7].Text = "OPERAÇÃO"; gvDt.HeaderRow.Cells[7].RowSpan = 2; gvDt.HeaderRow.Cells[8].Text = "TERMINAL"; gvDt.HeaderRow.Cells[8].RowSpan = 2; gvDt.HeaderRow.Cells[9].Text = "ÚLTIMO PORTO"; gvDt.HeaderRow.Cells[9].RowSpan = 2; gvDt.HeaderRow.Cells[10].Text = "PRÓXIMO PORTO"; gvDt.HeaderRow.Cells[10].RowSpan = 2; //Aplicar estilo de células individuais gvDt.HeaderRow.Cells[0].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[1].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[2].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[3].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[4].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[5].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[6].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[7].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[8].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[9].Style.Add("background-color", "green"); gvDt.HeaderRow.Cells[10].Style.Add("background-color", "green"); for (int i = 0; i < gvDt.Rows.Count; i++) { GridViewRow row = gvDt.Rows[i]; //Alterar cor de volta para branco row.BackColor = System.Drawing.Color.White; //Aplicar estilo de texto para cada linha row.Attributes.Add("class", "textmode"); //Aplicar estilo de células individuais do alternada Row if (i % 2 != 0) { row.Cells[0].Style.Add("background-color", "#FFFFFF"); row.Cells[1].Style.Add("background-color", "#FFFFFF"); row.Cells[2].Style.Add("background-color", "#FFFFFF"); row.Cells[3].Style.Add("background-color", "#FFFFFF"); row.Cells[4].Style.Add("background-color", "#FFFFFF"); row.Cells[5].Style.Add("background-color", "#FFFFFF"); row.Cells[6].Style.Add("background-color", "#FFFFFF"); row.Cells[7].Style.Add("background-color", "#FFFFFF"); row.Cells[8].Style.Add("background-color", "#FFFFFF"); row.Cells[9].Style.Add("background-color", "#FFFFFF"); row.Cells[10].Style.Add("background-color", "#FFFFFF"); } } gvDt.RenderControl(hw); } //rptData.RenderControl(hw); //estilo para formatar números para string string style = @"<style> .textmode { mso-number-format:\@; } </style>"; Response.Write(style); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); }
e está saindo assim:
essas tres colunãs que estão com rowspan = 1 devem ficar em baixo tendo uma com colspan = 3 acima delas.
Alguém já passou por isso ? Poderia ajudar ?