Buenos días
tengo el siguiente problema, espero que me puedan ayudar
tengo un listado que lo exporto a Excel.
tengo el siguiente código:
<script type="text/javascript">
function jsExportAcciones()
{
var tabla = document.getElementById('ctl00_cphPri_gvLista');
var count = tabla.rows.length - 1;
if (count == 0)
{
alert("No existen registros a exportar...");
return;
}
window.open('ExportData.aspx?Modulo=Acciones','','height=150,width=250,left=500,top=250;');
// __doPostBack('ctl00$cphPri$btnExportExcel', '');
}
</script>
La ventana ExportData.aspx tiene el siguiente código:
DataTable dt = new DataTable(mod);
string sMine = "Unidad : " + Var.GetData("glb_nom_unidad", Page);
string sDesde = "Desde : " + Var.GetData("glb_fec_ini", Page);
string sHasta = "Hasta : " + Var.GetData("glb_fec_fin", Page);
string sColumnFin = "";
DataSet ds = (DataSet)Session["ExportToExcel"];
if (mod == "Acciones")
{
dt = loadDataTableAcciones(ds);
sColumnFin = "AF";
}
// Generando el Excel
using (ExcelPackage pkg = new ExcelPackage())
{
// Creando Hoja
ExcelWorksheet sheet = pkg.Workbook.Worksheets.Add(mod);
// Cargando Archivo
sheet.Cells["A1:" + sColumnFin + "1"].Value = "Listado de " + mod;
sheet.Cells["A1:" + sColumnFin + "1"].Style.Font.Bold = true;
sheet.Cells["A1:" + sColumnFin + "1"].Style.Font.Name = "Arial";
sheet.Cells["A1:" + sColumnFin + "1"].Style.Font.Size = 20;
sheet.Cells["A1:" + sColumnFin + "1"].Merge = true;
sheet.Cells["A2:" + sColumnFin + "2"].Value = sMine;
sheet.Cells["A2:" + sColumnFin + "2"].Merge = true;
sheet.Cells["A3:" + sColumnFin + "3"].Value = sDesde;
sheet.Cells["A3:" + sColumnFin + "3"].Merge = true;
sheet.Cells["A4:" + sColumnFin + "4"].Value = sHasta;
sheet.Cells["A4:" + sColumnFin + "4"].Merge = true;
sheet.Cells["A6"].LoadFromDataTable(dt, true);
// Aplicando formato a la cabecera
using (ExcelRange rng = sheet.Cells["A6:" + sColumnFin + "6"])
{
rng.Style.Font.Bold = true;
rng.Style.Fill.PatternType = ExcelFillStyle.Solid;
rng.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
rng.Style.Font.Color.SetColor(Color.White);
}
// Setear la Auditoria
setAuditoria();
Byte[] fileBytes = pkg.GetAsByteArray();
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=" + mod + ".xlsx");
Response.Charset = "";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
StringWriter sw = new StringWriter();
Response.BinaryWrite(fileBytes);
Response.End();
Response.Write("<script language=javascript>window.close();</script>");
}
A mi me exporta sin problemas, he probado con algunos usuarios y si les funciona, pero a otros no, les sale un popup pequeño con error de runtime error que no puedo maximizarlo. solo puedo cerrar el popup y minimizarlo, pero no agrandarlo.
les faltará instalar algo en la pc del usuario para que pueda descargar? o tendrá que ver que tenga JavaScript la función? o tengo que instalar algo especial?
el archivo se va a la carpeta descargas por defecto y no deberían tener problema.
gracias por su ayuda.