コード例 #1
0
        protected void btnExportar_Click(object sender, EventArgs e)
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("SChqRef", typeof(string));
            dataTable.Columns.Add("SDesctrans", typeof(string));
            dataTable.Columns.Add("SFechaEfect", typeof(string));
            dataTable.Columns.Add("SFechaProc", typeof(string));
            dataTable.Columns.Add("SIndDebCre", typeof(string));
            dataTable.Columns.Add("SMonto", typeof(string));
            RespuestaStmrdsjv respuestaStmrdsjv = this.respuesta;

            if (respuestaStmrdsjv != null)
            {
                StmrdsjvDet[] stmrdsjvDetArray = respuestaStmrdsjv.stmjvCuentas.smtDetalle;
                for (int i = 0; i < (int)stmrdsjvDetArray.Length; i++)
                {
                    StmrdsjvDet stmrdsjvDet = stmrdsjvDetArray[i];
                    if (stmrdsjvDet != null)
                    {
                        DataRow sChqRef = dataTable.NewRow();
                        sChqRef["SChqRef"]    = stmrdsjvDet.SChqRef;
                        sChqRef["SDesctrans"] = stmrdsjvDet.SDesctrans;
                        DateTime fecha = Formatos.ISOToFecha(stmrdsjvDet.SFechaEfect);
                        sChqRef["SFechaEfect"] = fecha.ToString("dd/MM/yyyy");
                        DateTime dateTime = Formatos.ISOToFecha(stmrdsjvDet.SFechaProc);
                        sChqRef["SFechaProc"] = dateTime.ToString("dd/MM/yyyy");
                        sChqRef["SIndDebCre"] = stmrdsjvDet.SIndDebCre;
                        decimal num = Formatos.ISOToDecimal(stmrdsjvDet.SMonto);
                        if (stmrdsjvDet.SIndDebCre.Trim().Contains("0"))
                        {
                            num *= new decimal(-1);
                        }
                        sChqRef["SMonto"] = num;
                        dataTable.Rows.Add(sChqRef);
                    }
                }
                List <ExportUtils.ExportUtilDatos> exportUtilDatos = new List <ExportUtils.ExportUtilDatos>()
                {
                    new ExportUtils.ExportUtilDatos("Fecha Transacci&oacute;n", "SFechaProc", ExportUtils.Align.center, "", "#c12f2f", "#ffffff", false),
                    new ExportUtils.ExportUtilDatos("Fecha Efectiva", "SFechaEfect", ExportUtils.Align.center, "", "#c12f2f", "#ffffff", false),
                    new ExportUtils.ExportUtilDatos("Referencia", "SChqRef", ExportUtils.Align.center, "", "#c12f2f", "#ffffff", false),
                    new ExportUtils.ExportUtilDatos("Descripci&oacute;n", "SDesctrans", ExportUtils.Align.left, "", "#c12f2f", "#ffffff", false),
                    new ExportUtils.ExportUtilDatos("Monto", "SMonto", ExportUtils.Align.right, "", "#c12f2f", "#ffffff", false)
                };
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("<table>");
                stringBuilder.Append("<tr>");
                stringBuilder.Append("<td><b>Fecha:</b></td>");
                DateTime now = DateTime.Now;
                stringBuilder.Append(string.Concat("<td style='text-align:center;'>", now.ToString("dd/MM/yyyy"), "</td>"));
                stringBuilder.Append("</tr>");
                stringBuilder.Append("<tr>");
                stringBuilder.Append("<td><b>Criterio seleccionado:</b></td>");
                stringBuilder.Append(string.Concat("<td style='text-align:center;'>", this.liCritero.Text, "</td></tr>"));
                stringBuilder.Append("</table>");
                string[] afiliado = new string[] { "Movimientos_", base.Afiliado.sCedula, "_", null, null };
                afiliado[3] = DateTime.Now.ToString("ddMMyyyyhhmmss");
                afiliado[4] = ".xls";
                ExportUtils.Export2Excel(string.Concat(afiliado), stringBuilder.ToString(), dataTable, exportUtilDatos);
            }
        }