Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

from excel column to array

Participant ,
Jul 22, 2020 Jul 22, 2020

Hey!!

 

quick question.

I've extracted a cloumn from an excel sheet and i want to save this column in an array, how could i?

 

app.excelImportPreferences.properties = {
    sheetIndex : 0,
    aligmentStyle : AlignmentStyleOptions.SPREADSHEET,
    rangeName :"B2:B114" 
}

var myProperties = app.excelImportPreferences.properties;

	
myTextFrame.place(fileExcel, false, myProperties); 

 

TBH, I've taken this code from the community and now I'm wondering how to save the range in array. Because if i manged to save it in array then i can loop through it, to manuplate it.

thanks all. 

 

*I'm using javascript

TOPICS
How to , Import and export , InCopy workflow , Scripting , SDK
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2020 Jul 23, 2020
if (column1contentsArray[i].row == column1contentsArray[i++].row

 

This will always alert true, since you're just comparing if a Row Object is equal to another Row Object. You need to drill down into the cells' contents to evaluate. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2020 Jul 23, 2020

You need to drill down into the cells' contents to evaluate.

 

No. Because column1contentsArray[i] is already the contents of a cell.

But I wonder why there is a comparison with the contents where the iteration number is actually changed !

 

Our OP should do just a loop to see how the value of i will change in its course!

 

salshaw749, just run this little code in the ESTK ( ExtendScript Toolkit ), or if on Mac OS X where the ESTK cannot run anymore, test the script with an alert() instead of a $.writeln():

 

var counter = 0;
for(var i = 1; i < 10 ; i++)
{
	$.writeln( counter.toString()+"\t"+ i );
	$.writeln( counter.toString()+"\t"+ ( i === i++ ) ); // Always returns true
	counter++
};

 

Result:

0	1
0	true
1	3
1	true
2	5
2	true
3	7
3	true
4	9
4	true

 

See, how the value of i is jumping? That makes no sense at all.

Also note, that [i] is always the same as [i++], because: first the values are compared and then the value of i is counted up.

 

Regards,
Uwe Laubender

( ACP )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 27, 2020 Jul 27, 2020

I've solve it by using nested loop! which is seems time consuming but more accurate!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines