Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
Simple read and write in angular SheetJs not retaining style and macros of xlsm file

I have an xlsm file in assets folder, which I need to reading and returning as a download file. I am able to read the file.

The following code, which basically downloads the blob as a file, it retains the macros and styling.

this.http.get(..., {responseType: 'blob' as 'json'}).subscribe((response:any)=>{
    let dataType = response.type;
    let binaryData = [];
    binaryData.push(response);
    let downloadLink = document.createElement('a');
    downloadLink.href = window.URL.createObjectURL(new Blob(binaryData, {type: dataType}));
    if (this.fileName)
        downloadLink.setAttribute('download', this.fileName);
    document.body.appendChild(downloadLink);
    downloadLink.click();
});

However, I need to modify some data, and I am using SheetJs(xlsx) to modify it, but it is not retaining the macros and styling.

The following code uses xlsx to simply read and write it to a file and it is still losing macros and styling, only retaining the data.

this.http.get(..., {responseType: 'blob' as 'json'}).subscribe((response:any)=>{
    const reader: FileReader = new FileReader();
    reader.onload = (e: any) => {
        const bstr: string = e.target.result;
        const wb: XLSX.WorkBook = XLSX.read(bstr, {
            type: 'binary',
            bookVBA :true,
            cellStyles:true,
            cellHTML:true });
        XLSX.writeFile(wb, this.fileName,{
            type: 'binary',
            bookVBA:true,
            bookType: 'xlsm',
            cellStyles:true,
            bookSST:true,
        });
    };
    reader.readAsBinaryString(response);
});

even after setting bookVBA and cellStyles to true isn't resolving it.

I am using the latest version of SheetJs

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda