Skip to main content
Inspiring
August 24, 2012
Répondu

How to place one row from Excel at a time?

Hello everyone,

Actually the topic should be "How to set Excel import preferences?", but I am hesitant to change the old topic.

The problem is that app.excelImportPreferences doesn't define the import preferences. The code ignores the setting of the Excel import preferences and uses previous preferences from InDesign. I tried changing the table formatting from InDesign. I have tried app.excelImportPreferences.rangeName = "A3:H3";.

Below the code. Help appreciated!

Greetings,

bgfrhlp

P.S. I have tried to locate help from the forum and the internet, with no success.

doc = app.open(filePath = "d:/base.indt");

newFrame = doc.textFrames.add({geometricBounds:[6,28,37,84]});

setExcelImportPrefs ();

excelFile = new File ("d/file.xlsx");

newFrame.place (excelFile);

function setExcelImportPrefs(){

    with(app.excelImportPreferences){

        alignmentStyle = AlignmentStyleOptions.spreadsheet;

        decimalPlaces = 4;

        preserveGraphics = true;

        //Enter the range you want to import as "start cell:end cell".

        rangeName = "A3:H3";

        sheetIndex = 1;

        showHiddenCells = false;

        tableFormatting = TableFormattingOptions.excelFormattedTable;

        useTypographersQuotes = false;

        viewName = "";

    }

}

Message was edited by: bgfrhlp

Ce sujet a été fermé aux réponses.
Meilleure réponse par bgfrhlp

The code works well with old Excel files (.xls, Mac OS X). Maybe Adobe should do some updating...

P.S. Today I filed a bug report.

P.S.S. Works also in Windows 7 with .xls-files.

Message was edited by: bgfrhlp

1 commentaire

bgfrhlpAuteur
Inspiring
September 11, 2012

One obvious solution to the problem is to import all information from the Excel file at once and edit it in InDesign with a script.

doc = app.open(filePath = "d:/base.indt");

newFrame = doc.textFrames.add();

excelFile = new File ("d:/file.xlsx");

newFrame.place (excelFile);

excelData = newFrame.contents;

arrExcelData = excelData.split("\t");

etc.

P.S. How to fire the placegun? With app.place(); I get a loaded placegun, but I cannot find a way to fire it with a script.

bgfrhlpAuteurRéponse
Inspiring
October 2, 2012

The code works well with old Excel files (.xls, Mac OS X). Maybe Adobe should do some updating...

P.S. Today I filed a bug report.

P.S.S. Works also in Windows 7 with .xls-files.

Message was edited by: bgfrhlp