-2

I need to copy few cells from one excel to another excel using node js. Suppose i need to copy 3 cell values from 2 rows and assign to an array as below

First row

array[0,0] = A1 value

array[0,1] = B1 value

array[0,2] = C1 value

Second Row

array[1,0] = A2 value

array[1,1] = B2 value

array[1,2] = C2 value

After that i need to use the filled array and paste those values in another excel file in same location.That time i need to access below array structure to paste into exact location.

Excel 2

A1 = array[0,0].value

B1 = array[1,0].value

etc...

It does not behave the same way as we do in c#. Please let me know the code required in javascript.

OLIVER.KOO
  • 5,654
  • 3
  • 30
  • 62
Nalu
  • 195
  • 2
  • 13
  • Possible duplicate of [How can I create a two dimensional array in JavaScript?](https://stackoverflow.com/questions/966225/how-can-i-create-a-two-dimensional-array-in-javascript) – Kyle Muir Jul 06 '17 at 00:59

1 Answers1

0

As you may know, 2D array is nothing but array of array. That's exactly what you need to do in javascript to create one. For example :

// you can use an Array construct as well.
let my_2d_array = [];

my_2d_array[0] = [];

my_2d_array[0][0] = 'some value';

console.log(my_2d_array[0][0]);

Similarly you can create an array of objects as well, based on your requirement.

Hope this helps !

Saurabh Verma
  • 483
  • 1
  • 4
  • 17