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

355
Visualizações
How to print table in excel same order by using XLSX library in react js?

**Below is the object that I would like to print ** I am using XLSX *I need output as it is *

const handleClick = () => {
var wb = XLSX.utils.book_new();
var ws = XLSX.utils.json_to_sheet(arrayofobjects);
XLSX.utils.book_append_sheet(wb, ws, 'Test');
XLSX.writeFile(wb, 'file.xlsx');

};

  let arrayofobjects =[
{
  "00": 4,
  "01": 6,
    "10": 12,
    "11": 7,
},
{
  "00": 7,
  "01": 7,
    "10": 4,
    "11": 5, 
}

]

But I am getting output in another order in excel

first I am getting 10,11 later I am getting 00,01

This is what I am expecting

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

What you are missing is a header array in the desired order.

for instance

// defined array of your headers
const header = ["00", "01", "10", "11"]

// create workbook as usual
const wb = XLSX.utils.book_new();

// here you pass an additional variable called header
const ws = XLSX.utils.json_to_sheet(
    arrayofobjects,
    {header:header}, //you can also use {header} but for simplicity's sake i left it as is
);

about 4 years ago · Juan Pablo Isaza Relatório
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