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

how to read entire column using script without ignore some data

Participant ,
Jul 27, 2020 Jul 27, 2020

Copy link to clipboard

Copied

HEY all!

 

I'm trying to read a range of data from excel sheet and it works, but the problem the script dosn't read the entire column. i though that the type of the font or somthing but it's not.

I've print the data usein alert that's what i recive 

 

(1,1,1,1,2,2,2,2,,,,,,,)

 

i've more but it seems that the script dont read it.

 

so let me walk you through the code so you guys maybe see what it is wrong,

first i specify the range

 

	tmp_textframe.place(path,true)

 

 

save the range in varbile so i can manuplate

 

var column1contentsArray = tmp_textframe.texts[0].tables[0].columns[0].contents;

 

 

and here i'm save the varible in array so also i can manuplate and the alert

 

 

for(var i = 1; i < column1contentsArray.length; i++){
					idArr.push(column1contentsArray[i])
				
				 }
				 alert(idArr)

 

 

so, any one knows what they ignore the rest???

thanks guys again

TOPICS
Activation billing and install , Bug , EPUB , Feature request , How to , Import and export , InCopy workflow , Performance , Print , Publish online , Scripting , SDK , Sync and storage , Type

Views

393

Translate

Translate

Report

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

correct answers 2 Correct answers

Participant , Jul 29, 2020 Jul 29, 2020

UPDATE:

I've changed the size of the

autoSizingType

to this value 1752070000, which i've taken it from here http://jongware.mit.edu/idcs6js/pe_AutoSizingTypeEnum.html

now i can see the entire column  in the textframe but still when i start working with column some of the data that in the end ignorde and the alert showing them as in empty string. 

Votes

Translate

Translate
Participant , Jul 29, 2020 Jul 29, 2020

OTHER UPDATE:

I've managed to read the entire column by this line

tmp_textframe.place(path, true)
				
				tmp_textframe=tmp_textframe.parentStory.contents.split('\r')

 

Votes

Translate

Translate
Community Expert ,
Jul 27, 2020 Jul 27, 2020

Copy link to clipboard

Copied

Are the missing values just text values or there is something special about those cells, like if it has a textframe placed inside the cell, or the cell is merged etc. Try the following

 

var idArr = tmp_textframe.tables[0].columns[0].cells.everyItem().contents

 

-Manan

Votes

Translate

Translate

Report

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 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

The line you shared is the same one i'm using but i need the loop and the other array to manuplate the data.

Votes

Translate

Translate

Report

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 27, 2020 Jul 27, 2020

Copy link to clipboard

Copied

Hi salshaw749,

the array in your screenshot is just showing empty cells at the end. Means: No contents. Nevertheless a slot in the array is reserved. Even if it is empty. The array's length should be the number of cells in your table column. How many cells are in that column? How many do you excpect?

 

All other cells are populated with text.

What's not showing in your alert is the contents of the first cell. Why?

You begin your loop with 1 and not with 0. Counting starts with 0.

 

FWIW: If you want to show all the contents of the array you need no loop.

You can simply do it like that:

alert( column1contentsArray );

 

Or if you need one string with the contents of each cell in one line you could do:

alert( column1contentsArray.join("\r") );

 

But try this only on columns with not so much cells.

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I discoverd what is the problem! it's the size of the table. it's propotion with the page so it reads only the data the fits the table, if the data exceeds the limtation it dosn't read it!

 

this is the size 

var tmp_textframe = doc.pages[0].textFrames.add()
		tmp_textframe.properties = {
			textFramePreferences:{
				autoSizingReferencePoint:1953459301,
				autoSizingType:1752069993,
			}
		}

i want it to be more flex but i dont know how, so it can read the entire row, i'm going to delet the table from the UI at the end so there is no problem if it's exceed the layout of the page.

Votes

Translate

Translate

Report

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 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

Hi salshaw749,

then one strategy would be to flow in all the table before working with property contents of columns.

Add pages and text frames and thread the frames. Because a table can exceed the width of a text frame you could also change the width of the columns as a first step.

 

Regards,

Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

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 28, 2020 Jul 28, 2020

Copy link to clipboard

Copied

Hey Uwe, thanks for asking. How to change the width? I've tried to set these prefrences but didnt work for me

	tmp_textframe.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_AND_WIDTH_PROPORTIONALLY;
	tmp_textframe.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.CENTER_POINT

Votes

Translate

Translate

Report

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 29, 2020 Jul 29, 2020

Copy link to clipboard

Copied

UPDATE:

I've changed the size of the

autoSizingType

to this value 1752070000, which i've taken it from here http://jongware.mit.edu/idcs6js/pe_AutoSizingTypeEnum.html

now i can see the entire column  in the textframe but still when i start working with column some of the data that in the end ignorde and the alert showing them as in empty string. 

Votes

Translate

Translate

Report

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 29, 2020 Jul 29, 2020

Copy link to clipboard

Copied

OTHER UPDATE:

I've managed to read the entire column by this line

tmp_textframe.place(path, true)
				
				tmp_textframe=tmp_textframe.parentStory.contents.split('\r')

 

Votes

Translate

Translate

Report

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 29, 2020 Jul 29, 2020

Copy link to clipboard

Copied

LATEST

"How to change the width?"

You would not have to change the width of the text frame.

Just change the width of the table.

Last property in the list of properties for object table:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Table.html

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate

Report

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