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

238
Visualizações
Excel download with the right format

im needing of some advice on how i could get my excel download to the right format. i was wondering if there is any tag that is used in html -> excel download as shown below.

I have declared my excel variables as shown below,

    var uri = 'data:application/vnd.ms-excel;base64,'
        , tmplWorkbookXML = '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">'
            + '<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"></DocumentProperties>'
            + '{worksheets}</Workbook>'
        , tmplWorksheetXML = '<Worksheet ss:Name="{nameWS}"><Table>{rows}</Table></Worksheet>'
        , tmplCellXML = '<Cell><Data ss:Type="{nameType}">{data}</Data></Cell>'
        , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
        , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
    var ctx = "";
    var workbookXML = "";
    var worksheetsXML = "";
    var rowsXML = "";

The logic i came out with to append my data to excel .

 for (let i = 0; i < _filterData.length; i++) {
                rowsXML += '<Row>'
                for (let a = 0; a < _filterData[i].getAppliedValues().length; a++) {
                    let filtervalue = _filterData[i].getAppliedValues()[a].formattedValue
                    ctx = {
                        nameType: 'String',
                        data: filtervalue
                    };
                    rowsXML += format(tmplCellXML, ctx);
                }
                rowsXML += '</Row>'
            }

I am able to download my excel however my excel is not in the format i wanted. image below is how it looks like

enter image description here

The expected result on how the export should look like shown below , in the above script , i am using <'row'> to append my data. how could i swap from vertical insert to horizontal insert. is this possible or the logic should be re-written enter image description here

Also, i am wondering is it possible to set my column to a certain width size so that when excel has been downloaded , we wont need to stretch the column manually. i believed that i need to make adjustment to my first code snippet. i tried researching online but i couldnt find any information on this as most methods are using third party library, i am not using those due to company restriction. Any approach or resources that i look up to ?

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