Script to insert a formatted Excel table not working

New Here ,
Apr 01, 2021 Apr 01, 2021

Copy link to clipboard

Copied

I have been attempting to write a script to insert a formatted Excel table - ideally to run without displaying the options dialog. However, changing the TableFormattingOptions to excelFormattedTable seems to have no effect.

 

Here is the script extract in question:

app.excelImportPreferences.tableFormatting = TableFormattingOptions.EXCEL_FORMATTED_TABLE;
alert(app.excelImportPreferences.tableFormatting);
myTextFrame.place(myFile,true);

 

When running the script, the alert shows the tableFormatting has been set to EXCEL_FORMATTED_TABLE:

image.png

 

However the options dialog shows the Formatting option remains as Unformatted Table.

Screenshot 2021-04-01 at 11.19.18.png

 

 

 

Incidently, when I set tableFormatting to TableFormattingOptions.EXCEL_UNFORMATTED_TABLE, it does work as I would expect.

 

Am I doing something incorrectly, or is this a bug? If so is there a work around, or do I just have to rely on using the options dialog?

 

TOPICS
Bug, Import and export, Scripting

Views

160

Likes

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
Adobe Community Professional ,
Apr 02, 2021 Apr 02, 2021

Copy link to clipboard

Copied

I believe you have to also set the alignment options for the incoming cells. Just tested successfully on my Big Sur Mac running ID 16.0.1: 

 

app.excelImportPreferences.tableFormatting = TableFormattingOptions.EXCEL_FORMATTED_TABLE;
app.excelImportPreferences.alignmentStyle = AlignmentStyleOptions.SPREADSHEET;
alert(app.excelImportPreferences.tableFormatting);
myTextFrame.place(myFile,true);

 

 

Likes

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
New Here ,
Apr 04, 2021 Apr 04, 2021

Copy link to clipboard

Copied

Thanks for the reply. Unfortunately this solution does not seem to work when I try it – the behaviour remains the same. Again, if someone places an unformatted table before running the script, the script inserts an unformatted table though the tableFormatting and alignmentStyles are set as advised. I have tested it on versions 15.1.3 and 16.1, both on mac (Mojave). I am currently thinking it must be a bug.

Likes

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
Adobe Community Professional ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

Hi Richard,

could it be that you are tricked by that issue, a dialog box that could pop up when an Excel file exceeds a certain complexity or length and that suggests to switch off importing formatted tables ?

 

ExcelImport-2020-Files-4.PNG

The message reads:

"You can speed up import if you place the cells unformatted. Would you like to speed up import this way?"

[ ] Do not show again

 

( Roughly translated from my German InDesign. )

 

If you now check that dreaded option "Do not show again" and press the Enter key to never see this dialog again you are tricked, because you automatically agreed with that offer, because "Yes" is the active button! From then on tables will always be placed unformatted independently from the import options you do before.

 

Read into this where the issue came up lately:

 

Importing excel into Indesign
michaelv71857798, Mar 29, 2021
https://community.adobe.com/t5/indesign/importing-excel-into-indesign/m-p/11934841#M420277

 

My answer in the same thread, where I tried to solve this riddle:
Laubender, Apr 15, 2021
https://community.adobe.com/t5/indesign/importing-excel-into-indesign/m-p/11972051#M422329

 

I must admit that I also was tricked, but I did not check "[ ] Do not show again", so I was able to see what I did wrong.

 

Regards,
Uwe Laubender

( ACP )

 

Likes

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
Adobe Community Professional ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

LATEST

Hi Richard,

will your code work differently for small tables, just some table rows?

Does it make a difference if you test a small table vs a complex and long one?

 

Regards,
Uwe Laubender

( ACP )

Likes

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