Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

488
Vistas
How to open a excel file after it gets downloaded in javascript?

I download an excel file (.xls) by using below code:

JavaScript Code:

window.location = result.filename;

After downloading, I want to open a excel file automatically without clicking on it. I want JavaScript code for opening excel file automatically.

I tested with following function code. But it runs only in Internet Explorer, not in Mozilla, Chrome...

function openExcelFile(strFilePath) {
var objExcel;
objExcel = new ActiveXObject("Excel.Application");
objExcel.Visible = true;
objExcel.Workbooks.Open(strFilePath);
}

By using above code, the excel file open automatically after it gets downloaded in Internet Explorer.

I want JavaScript code for opening excel file automatically after downloaded by working in all browsers.

How can I achieve this?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

pass the excel file path to the controller. it will works fine with all browsers.

public ActionResult GetFile(string path)
{

    string extension = new FileInfo(path).Extension;
    if (extension != null || extension != string.Empty)
    {
        switch (extension)
        {
            case ".xls":
                return File(path, "application/vnd.ms-excel");
            case ".xlsx":
                return File(path, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        }
    }
    return View("Index");
}
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda