Skip to main content
lfcorullon13651490
Legend
January 11, 2019
Question

How many sheets in Excel file

  • January 11, 2019
  • 3 replies
  • 648 views

Hello!

There is a way to know how many sheets an Excel file has to loop and then import them?

What about the import options dialog... can JS code automate the filling for, for example, the Cell Range field?

I need to deal with Excel files that has more than one sheet in it. If I do it manually and choose to show the import options dialog, I have, in Cell Range field, this strange "_xlnm.Print_Area" option, so, I want to use it, because it results me a cleaner InDesign table.

This topic has been closed for replies.

3 replies

Stefan Rakete
Inspiring
January 11, 2019

With JavaScript you cound set the excelImportPreference:

app.excelImportPreferences.sheetIndex = 2;

If you don't run into an error, you know you have an Excel file with at least two sheets.

Thx Stefan

Inspiring
January 11, 2019

-- In Applescript:

tell application "Microsoft Excel"

  set theCount to count sheets --> 4

  (* -- another way:

  -- get the sheet names:

       set xlNameList to name of every sheet --> {"Sheet1", "Sheet2", "Sheet3", "Sheet4"}

  -- and count the names:

       set xlNameListCount to count xlNameList

  *)

end tell

Community Expert
January 11, 2019

I could not find anything in the scripting API that gives the count of sheets available in Excel file. You could use VBScript or Applescript to get this info from your jsx.

-Manan

-Manan