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

169
Vistas
Rows of data/strings to columns

I have some data on my front-end that is just an array of arrays with numbers, i.e.:

data: number[][]

data = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]

What I would like to do is to click a button, and then these three arrays are copied into my clipboard, so that I can paste it into e.g. Excel.

For that I do the following:

type Props = {
  exportData: number[][];
};

const ExportBtn = ({ exportData }: Props) => {

  const copy = () => {
    let data = exportData.map((lines) => lines.join("\n")).join("\n");

    navigator.clipboard.writeText(data);

  };

  return (
    <>
      <button type="button" onClick={copy}> Copy </button>
    </>
  );
};

export default ExportBtn;

If I console log the data from the copy function, the result is three rows with the above content, i.e.:

1  2  3  4
2  3  4  5
3  4  5  6

And since this is going to be pasted into Excel I would like this to be transposed, so the result looks like:

1  2  3
2  3  4
3  4  5
4  5  6

But I am not sure what I need to do in order to make this happen ?

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