2 Replies Latest reply on May 19, 2009 7:29 AM by Tony Tuneson

    [CS3]How to export a table in InDesign to an excel file?

    KatMus Level 1

      Hi,

       

      Can any one tell me how to script the process of exporting a table to excel file in InDesign CS3 using javascript?

       

      Thanks in advance.

       

       

      myRiaz

        • 1. Re: [CS3]How to export a table in InDesign to an excel file?
          Peter Kahrel Adobe Community Professional & MVP

          In the object-model viewer, look under the convertToText () method of tables:

           

          myTable.convertToText ("\t", "\r");

           

          converts the table to text, with tabs as column separators and returns as line separators. Then import the table in Excel.

           

          Peter

          • 2. Re: [CS3]How to export a table in InDesign to an excel file?
            Tony Tuneson Level 1

            Sorry, no javaScript, but here are some lines from a localization tool that I made in VB. I simply loop through the Rows and Columns and use the Excel DOM to fill the Excel-cells.

            Of course you can read amended/localized Excel files back into inDesign the same way, provided that the tables match (nr of rows and columns).

            Afterwards you could loop through the characters of each cell to apply the formatting that you want to keep in Excel, such as SuperScripts.

            Hope it helps you.

             

            Set myExcel = CreateObject("Excel.Application")

            myExcel.Visible = True
            Set myTableBook = myExcel.Workbooks.Add
            Set myTableSheet = myTableBook.Worksheets.Item(1)

            myTableSheet.Columns.ColumnWidth = 35
            myTableSheet.Cells.VerticalAlignment = xlVAlignTop
            myTableSheet.Cells.WrapText = True

             

            For R = 1 To myTable.Rows.Count
                Set myTableRow = myTable.Rows.Item(R)
                For C = 1 To myTableRow.Cells.Count
                    Set myTableCell = myTableRow.Cells.Item(C)
                    If Len(myTableCell.Contents) = 0 Then
                        myTableSheet.Cells(R, C) = ""
                    Else
                        myTableSheet.Cells(R, C) = myTableCell.Contents
                        myTableSheet.Cells(R, C).Value = Replace(myTableSheet.Cells(R, C).Value, "1397058884", "—")
                        myTableSheet.Cells(R, C).Value = Replace(myTableSheet.Cells(R, C).Value, Chr(13), Chr(10))
                    End If
                Next C
            Next R

             

            good luck

            TonyT