We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.
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:
However the options dialog shows the Formatting option remains as Unformatted Table.
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?
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);
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.
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 ?
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
My answer in the same thread, where I tried to solve this riddle:
Laubender, Apr 15, 2021
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.
( ACP )
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?
( ACP )