Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!