protected void ExportToExcel(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=Prazos.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; using (StringWriter sw = new StringWriter()) { HtmlTextWriter hw = new HtmlTextWriter(sw); //To Export all pages GridTodosProjetos.HeaderRow.BackColor = Color.White; foreach (TableCell cell in GridTodosProjetos.HeaderRow.Cells) { cell.BackColor = GridTodosProjetos.HeaderStyle.BackColor; } foreach (GridViewRow row in GridTodosProjetos.Rows) { row.BackColor = Color.White; foreach (TableCell cell in row.Cells) { if (row.RowIndex % 2 == 0) { cell.BackColor = GridTodosProjetos.AlternatingRowStyle.BackColor; } else { cell.BackColor = GridTodosProjetos.RowStyle.BackColor; } cell.CssClass = "textmode"; } } GridTodosProjetos.RenderControl(hw); //style to format numbers to string string style = @"<style> .textmode { } </style>"; Response.Write(style); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); } }
protected void CarregarGrids() { using (var bd = new DAOOasis()) { var dados = bd.RelatorioPrazosObjeto(Convert.ToInt32(ddlRequisitos.SelectedValue), Convert.ToInt32(ddlAnalistas.SelectedValue), DropDownList1.SelectedValue); GridPropostas.DataSource = dados.Where(x => x.TemProposta && !x.TemPropostaEnviada).OrderBy(x => Convert.ToDateTime(x.PRAZO_PROPOSTA)).ToList(); GridPropostas.DataBind(); GridExecucao.DataSource = dados.Where(x => x.TemAceiteProposta && x.TemPendenciaExecucaoCast).OrderBy(x => Convert.ToDateTime(x.PRAZO_PARCELA)).ToList(); GridExecucao.DataBind(); GridFecharParcela.DataSource = dados.Where(x => x.TemPendenciaFecharParcela).OrderBy(x => Convert.ToDateTime(x.PRAZO_PARCELA)).ToList(); GridFecharParcela.DataBind(); GridTodosProjetos.DataSource = dados; GridTodosProjetos.DataBind(); } }