How to format paragraphs in a table cell programmatically

I am adding three paragraphs to a cell:
this.currentTable.rows[0].cells[0].contents =
  record[this.GUIDE_LOCNAME_ENG] + "\r" +
  record[this.GUIDE_LOCNAME_FR] + "\r" +
  record[this.GUIDE_LOCDESC] +"\r" +
  record[this.LATITUDE] + "N " + record[this.LONGITUDE] +"W";
I am still relatively new to the InDesign model and my head hurts
I want to access the paragraphs and change the paragraph style of each paragraph to three different paragraph styles. I have searched and I am stymied.
Thanks in advance
Bill

I count 4 paragraphs there! Anyway, once you've added the contents to
the cell, it should be a simple matter of:
para1 = this.currentTable.rows[0].cells[0].paragraphs[0];
para2 = this.currentTable.rows[0].cells[0].paragraphs[1];
etc.
then, to apply a paragraph style:
myParaStyles = app.activeDocument.paragraphStyles;
para1.appliedParagraphStyle = myParaStyles.itemByName("aStyleName");
etc.
(If you para styles are in groups, you need to target the group first
before the paragraph style).

Similar Messages

  • How to remove paragraph breaks from table cells?

    I need to remove paragraph breaks from selection of cells in my table and replace them with a space and a dot.
    Tried this and it did not work:
    =SUBSTITUTE(AH2,CHAR(10)," .")
    I also tried to use find and replace, but it didn't work either.
    Any ideas?

    Berbato wrote:
    I need to remove paragraph breaks from selection of cells in my table and replace them with a space and a dot.
    Tried this and it did not work:
    =SUBSTITUTE(AH2,CHAR(10)," .")
    Did you read the error message returned by the app ?
    I also tried to use find and replace, but it didn't work either.
    I'm sure that you didn't inserted the correct value in the "Find/Search" field but I can't guess what was the one which you inserted ? .
    I selected the character to replace, Copy it then pasted it in the Find/Search field.
    Yvan KOENIG (VALLAURIS, France) jeudi 27 janvier 2011 17:46:44

  • How to format paragraph string to show content left, Right or middle of pdf document using iTextsharp ' vb

    Dear All
    how to format paragraph string to show content left, Right or middle of pdf document using iTextsharp in visual basic and absolute position on the document.
    Thanks

     Here is one more example that i have modified the GetCell function so that you can use it for adding all the cells to the document.  It takes several arguments to specify everything you need to create each cell.  It now lets
    you specify the Text, the Text Alignment, the Text Font and color, weather the cell shows the Border, the BackColor of the cell, and the Padding values for the Left, Right, Top, and Bottom.
     If you study the code you should be able to figure out how it works.  From here you can figure out the rest of what you need to do and how to use the
    GetCell function.
     With one quick google search for "iTextSharp Documentation" the first link to pop up was this link.
    iTextSharp Documentation
    Imports System.IO
    Imports Its = iTextSharp.text
    Public Class Form1
    Private dt As New DataTable
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    dt.Dispose()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    dt.Columns.Add("Name")
    dt.Columns.Add("Age")
    dt.Columns.Add("Birth Date")
    dt.Rows.Add(New Object() {"Johnny", "23", Now.AddYears(-23).ToString})
    dt.Rows.Add(New Object() {"Frank", "41", Now.AddYears(-41).ToString})
    dt.Rows.Add(New Object() {"Rex", "33", Now.AddYears(-33).ToString})
    dt.Rows.Add(New Object() {"Kim", "26", Now.AddYears(-26).ToString})
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim MyPdfFilePath As String = "C:\TestFolder\MyPdf.pdf"
    Dim pSize As New Its.Rectangle(Its.PageSize.A4)
    Dim PdfDoc As Its.Document = New Its.Document(pSize, 10, 10, 10, 10)
    Dim PdfImage As New Its.Jpeg(New Uri("C:\TestFolder\MyLogo.jpg"))
    PdfImage.Alignment = Its.Jpeg.ALIGN_CENTER
    Dim pTable As New Its.pdf.PdfPTable(1)
    pTable.AddCell(getCell("Name : " & TextBox1.Text, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 15, Its.BaseColor.BLACK), False, Its.BaseColor.WHITE, 10, 0, 0, 0))
    pTable.AddCell(getCell("Policy : " & TextBox2.Text, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 20, Its.BaseColor.RED), False, Its.BaseColor.WHITE, 10, 20, 0, 0))
    Dim cTable As New Its.pdf.PdfPTable(dt.Columns.Count)
    For Each col As DataColumn In dt.Columns
    cTable.AddCell(getCell(col.ColumnName, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 12, Its.BaseColor.WHITE), True, Its.BaseColor.BLUE, 3, 5, 0, 0))
    Next
    Dim tblfont As Its.Font = Its.FontFactory.GetFont("Arial", 10, Its.BaseColor.BLACK)
    For Each row As DataRow In dt.Rows
    cTable.AddCell(getCell(row.Field(Of String)("Name"), Its.pdf.PdfPCell.ALIGN_LEFT, tblfont, True, Its.BaseColor.WHITE, 3, 4, 3, 0))
    cTable.AddCell(getCell(row.Field(Of String)("Age"), Its.pdf.PdfPCell.ALIGN_CENTER, tblfont, True, Its.BaseColor.WHITE, 3, 4, 0, 0))
    cTable.AddCell(getCell(row.Field(Of String)("Birth Date"), Its.pdf.PdfPCell.ALIGN_RIGHT, tblfont, True, Its.BaseColor.WHITE, 3, 4, 0, 3))
    Next
    Using fs As New FileStream(MyPdfFilePath, FileMode.Create, FileAccess.Write, FileShare.None)
    Using pdfWrite As Its.pdf.PdfWriter = Its.pdf.PdfWriter.GetInstance(PdfDoc, fs)
    PdfDoc.Open()
    PdfDoc.Add(PdfImage)
    PdfDoc.Add(pTable)
    PdfDoc.Add(cTable)
    PdfDoc.Close()
    End Using
    End Using
    PdfDoc.Dispose()
    End Sub
    ''' <summary>Creates a new cell for the table.</summary>
    ''' <param name="text">The text string for the cell.</param>
    ''' <param name="alignment">Alighnment for the text string.</param>
    ''' <param name="textfont">The font used for the text string.</param>
    ''' <param name="border">True to show the cell border. False to hide the cell border.</param>
    ''' <param name="backcolor">The background color of the cell.</param>
    ''' <param name="padtop">The amount of padding on the top of the text string.</param>
    ''' <param name="padbottom">The amount of padding on the bottom of the text string.</param>
    ''' <param name="padleft">The amount of padding on the left of the text string.</param>
    ''' <param name="padright">The amount of padding on the right of the text string.</param>
    Public Function getCell(ByVal text As String, ByVal alignment As Integer, ByVal textfont As Its.Font, ByVal border As Boolean, ByVal backcolor As Its.BaseColor, ByVal padtop As Single, ByVal padbottom As Single, ByVal padleft As Single, ByVal padright As Single) As Its.pdf.PdfPCell
    Dim cell As New Its.pdf.PdfPCell(New Its.Phrase(text, textfont))
    cell.BackgroundColor = backcolor
    cell.PaddingLeft = padleft
    cell.PaddingRight = padright
    cell.PaddingTop = padtop
    cell.PaddingBottom = padbottom
    cell.HorizontalAlignment = alignment
    If Not border Then cell.Border = Its.pdf.PdfPCell.NO_BORDER
    Return cell
    End Function
    End Class
    If you say it can`t be done then i`ll try it

  • How can I copy and paste table cells from Pages into InDesign with minimum reformating?

    How can I copy and paste table cells from Pages into InDesign with minimum reformating?

    Do you mean you want to retain the formatting from Pages, or retain formatting already applied in ID?

  • How can I write into a table cell (row, column are given) in a databae?

    How can I write into a table cell (row, column are given) in a database using LabVIEW Database Toolkit? I am using Ms Access. Suppose I have three columns in a table, I write 1st row of 1st column, then 1st row of 3rd column. The problem I am having is after writing the 1st row 1st column, the reference goes to second row and if I write into 3rd column, it goes to 2nd row 3rd column. Any suggestion? 
    Solved!
    Go to Solution.

    When you do a SQL INSERT command, you create a new row. If you want to change an existing row, you have to use the UPDATE command (i.e. UPDATE tablename SET column = value WHERE some_column=some_value). The some_column could be the unique ID of each row, a date/time, etc.
    I have no idea what function to use in the toolkit to execute a SQL command since I don't use the toolkit. I also don't understand why you just don't do a single INSERT. It would be much faster.

  • How to populate change from one Table cell to more Tables??

    Dear Friends:
    I have following successfully running code, each can populate 1 table cell updating in ChangeTableSelectionMain1 change to another table in ChangeTableSelectionMain1 also, or populate 1 table cell in ChangeTableSelectionSub1 change to another table in ChangeTableSelectionSub1 also, But cannot populate table cell updating in ChangeTableSelectionMain1 to ChangeTableSelectionSub1, Please advice how to make populating table cell updating in ChangeTableSelectionMain1 to ChangeTableSelectionSub1 successful??
    Thanks.
    [1]. main code:
    package com.com;
    import java.awt.BorderLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    import java.awt.GridLayout;
    public class ChangeTableControl1 implements java.io.Serializable{
         private JFrame                frame;
         public static void main(String args[]) {
              try {
                   ChangeTableControl1 window = new ChangeTableControl1();
                   window.frame.setVisible(true);
              } catch (Exception e) {
                   e.printStackTrace();
          * Create the application
         public ChangeTableControl1() {
              initialize();
          * Initialize the contents of the frame
         private void initialize() {
              frame = new JFrame();
              frame.setBounds(0, 0, 1500, 675);
              final ChangeTableSelectionMain1      c1      = new ChangeTableSelectionMain1();
              final ChangeTableSelectionSub1           c2      = new ChangeTableSelectionSub1();
              JSplitPane sp = new JSplitPane();          
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JPanel panel = new JPanel();
              panel.setLayout(new GridLayout(1, 2));
              frame.getContentPane().add(panel, BorderLayout.CENTER);
              sp.setLeftComponent(c1);
              sp.setRightComponent(c2);
              sp.setResizeWeight(0.5);
              panel.add(sp);// add right part
                frame.addWindowListener(new WindowAdapter() {
                     public void windowClosing(WindowEvent e) {
                         System.exit(0);
                 frame.pack();
                 frame.setVisible(true);
    }[2]. ChangeTableSelectionSub1
    package com.com;
    import javax.swing.JTable;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.event.TableModelEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import java.awt.FlowLayout;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    import java.text.SimpleDateFormat;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.BorderLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTable;
    public class ChangeTableSelectionSub1 extends JPanel{
           protected         JButton                bt11 = new JButton("Insert before");
           protected         JButton                bt22 = new JButton("Insert after");
           protected         JButton                bt33 = new JButton("Delete");
           protected      ChangeTableSelectionMain1 lm = new ChangeTableSelectionMain1();
    public ChangeTableSelectionSub1() {
         JPanel pnl = new JPanel();
         pnl.setMinimumSize(new Dimension(200,600));
              //pnl.setPreferredSize(new Dimension(800,600));
              final JTable tbl1 = new JTable(lm.data,lm.columnNames);
              final JTable tbl2 = new JTable(lm.data,lm.columnNames);
              JScrollPane scr1 = new JScrollPane(tbl1);
              JScrollPane scr2 = new JScrollPane(tbl2);
              lm.tbl1.getSelectionModel().addListSelectionListener(new ListSelectionListener()
              public void valueChanged(ListSelectionEvent lse)
                   if (lm.tbl1.getSelectedRow()!=-1)
                        tbl2.clearSelection();
                        System.out.print("[1]. LongguChangeTableSelectionSub get msg from LongguChangeTableSelectionMain");
                        tbl1.clearSelection();
                        revalidate();
              lm.tbl2.getSelectionModel().addListSelectionListener(new ListSelectionListener()
         public void valueChanged(ListSelectionEvent lse)
              if (tbl2.getSelectedRow()!=-1)
                   tbl1.clearSelection();
              System.out.print("[2]. LongguChangeTableSelectionSub get msg from LongguChangeTableSelectionMain");
              revalidate();
         pnl.setLayout(new FlowLayout());
         pnl.add(scr1);
         pnl.add(scr2);
         this.add(pnl);
    public static void main(String []args)
         ChangeTableSelectionSub1 c = new ChangeTableSelectionSub1();
         JFrame frm = new JFrame();
         frm.setSize(920,400);
         frm.getContentPane().add(c);
         frm.setVisible(true);
    }[3]. ChangeTableSelectionMain1
    package com.com;
    import javax.swing.JTable;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.JScrollPane;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import java.awt.FlowLayout;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.*;
    import javax.swing.*;
    public class ChangeTableSelectionMain1 extends JPanel{
           protected         JButton                bt11 = new JButton("Insert before");
           protected         JButton                bt22 = new JButton("Insert after");
           protected         JButton                bt33 = new JButton("Delete");
           protected String[] columnNames = {"First Name",
                        "Last Name",
                        "Sport",
                        "# of Years",
                        "Vegetarian"};
           protected Object[][] data = {
              {"Mary", "Campione","Snowboarding", new Integer(5), new Boolean(false)},
              {"Alison", "Huml","Rowing", new Integer(3), new Boolean(true)},
              {"Kathy", "Walrath","Knitting", new Integer(2), new Boolean(false)},
              {"Sharon", "Zakhour","Speed reading", new Integer(20), new Boolean(true)},
              {"Philip", "Milne","Pool", new Integer(10), new Boolean(false)} };
           protected JTable tbl1 = new JTable(data,columnNames);
           protected JTable tbl2 = new JTable(data,columnNames);
    public ChangeTableSelectionMain1() {
         JPanel pnl = new JPanel();
         pnl.setMinimumSize(new Dimension(200,600));
              //pnl.setPreferredSize(new Dimension(800,600));
              JScrollPane scr1 = new JScrollPane(tbl1);
              JScrollPane scr2 = new JScrollPane(tbl2);
              tbl1.getSelectionModel().addListSelectionListener(new ListSelectionListener()
              public void valueChanged(ListSelectionEvent lse)
                   if (tbl1.getSelectedRow()!=-1)
                        tbl2.clearSelection();
                   if (lse.getValueIsAdjusting())
                       System.out.println("Selected from " + lse.getFirstIndex() + " to " + lse.getLastIndex());
                   revalidate();             
              tbl2.getSelectionModel().addListSelectionListener(new ListSelectionListener()
         public void valueChanged(ListSelectionEvent lse)
              if (tbl2.getSelectedRow()!=-1)
                   tbl1.clearSelection();
                   revalidate();
         pnl.setLayout(new FlowLayout());
         pnl.add(scr1);
         pnl.add(scr2);
         this.add(pnl);
    public static void main(String []args)
         ChangeTableSelectionMain1 c = new ChangeTableSelectionMain1();
         JFrame frm = new JFrame();
         frm.setSize(920,400);
         frm.getContentPane().add(c);
         frm.setVisible(true);
    }Message was edited by:
    sunnymanman

    I have following successfully running code, each can populate 1 table cell updating in ChangeTableSelectionMain1 change to another table in ChangeTableSelectionMain1 also, or populate 1 table cell in ChangeTableSelectionSub1 change to another table in ChangeTableSelectionSub1 also, But cannot populate table cell updating in ChangeTableSelectionMain1 to ChangeTableSelectionSub1, Please advice how to make populating table cell updating in ChangeTableSelectionMain1 to ChangeTableSelectionSub1 successful??
    My brain hurts, does yours?

  • How to show combobox in a table cell

    Hi,
    I set combobox in a table cell but it shows when I click the cell.
    How can I set the combobox and it be visible since the table is showing.

    What you have already done, and the resulting behavior is unclear from your post. Post more details.

  • How to display system date on table cells

    hi all,
    I would like to display the PC date onto a specified cell on a table. I have attached here my vis. I don't know how to get the date displayed at the table cell On the front panel when I run it. Please help.
    Attachments:
    data.vi ‏32 KB
    getPCdate.vi ‏9 KB

    Hi,
    The table control is simply a 2D array of string. So all you need to do is to pick up the Date from the appropriate .vi and replace the array element (using replace array subset) and write the whole table back again. (Example attached for LV 6.0.x)
    // it takes almost no time to rate an answer
    Attachments:
    Untitled_1.vi ‏13 KB

  • How to stop editing in a table cell

    i m using JTextArea as renderer and editor for table cell. While editing i want to stop editing in that cell at some perticular instance. i have used stopCellEditing() function on TableCellEditor but still the Caret does not goes away and when i press any key it still types that character at that place. I want to hide the Caret and do not want any character to print in the cell after calling stopCellEditing().

    What you have already done, and the resulting behavior is unclear from your post. Post more details.

  • How to map column value (in table cell)

    Hi,
    My table, say product, has 'status' field (varchar(1))
    status = 0 -- unavailable product
    status = 1 -- avaialble product
    I want to map this value into readable 'available/unavailable'
    (a combo box cell editor) when I manipulate table cell (insert/search/modify)
    and status field correctly mapped into '0', '1'.
    Thanks,
    Tuan

    repost

  • How can I insert/move a table cell in Pages?

    I'm making labels for tab dividers (specifically, for dividers in comic book boxes) and I'm trying to figure out how I can insert an empty cell in the table. Or move the other cells over/down and have them "wrap" from the end of the row to the beginning of the next row if neccessary. Can this be done?

    KonKrypton wrote:
    Jerrold, I can do that, but I was hoping for a way to "scootch over" the cells so I can keep them in order. That would require me to cut and paste every cell from the target cell to the end of the document (or page). I have a feeling that what I'm looking for doesn't exist.
    Thanks, I appreciate the idea.
    Kon,
    It would be easy to move a group of rows, but there's no way to get it to snake down or up. This is a 2-D array, not not a linear array that has been meandered into a rectangle. You could write an expression to do this, but it would take several steps, and would involve a second table. You could also write an Applescript to do what you want. All of this seems a lot of work for what, as Peter notes, seems a rather simple result.
    Jerry

  • How to control background color of table cell in an html report?

    I am using Labview 6.1 to generate a report.  In that report there is a table created using the Append Numeric Table to Report VI.  I want to be able to programmatically control the background color of each cell in the table.  Also, how can I programmatically control the background color of the row and header cells of the same table.  I am also generating a second table in the same report using the Append Text Table to Report VI and I would like to programmatically control the background colors of the cells in that table as well.  Thanks.

    Hi epsilon-d...,
    i´m not sure if there is an ready to use function to do what you want, but you can enlarge the available function. Open the "Append Numeric Table to Report.vi" and go to the HTML Case. There you can see another vi which creates the html table. In the VI "HTML Report Table Row" you can add the option: bgcolor="your color" inside of the "TR" tag.
    Hope it helps.
    Mike

  • How can I set the af:table cell spacing ????

    Hi,
    I am using the af:table component and I need absolutely to set the cell spacing. I am afraid that it couldn't be possible.
    If you have any idea please dont hesitate.
    Many thanks

    Please lell me how can i create a TableModel , means
    we have to create a seperate class or I have to do
    like this---------------
    private TableModel myData;
    private JTable oTable = new JTable(myData);
    and call this method on table object
    int iRows = oTable.getRowCount();
    oTable.isCellEditable(iRows,2);\Something like this:
    public class MyTableModel extends DefaultTableModel {
        public boolean isCellEditable(int row, int col) {
            return false;
    }Or even better, extend AbstractTableModel. AbstractTableModel already overrides isCellEditable to return false.
    public class MyTableModel extends AbstractTableModel {
    }Graeme

  • How to show line feeds in table cell

    Dear Expert,
    Now we meet one question,we have a long text which include many line feeds,when show it in a cell of one table in smartform.we can only see the line feeds become to  some ##. not do the ENTER or TAB..
        For example, the show like below:
        ABECDEF#MNIOPHN
       not
       ABECDEF
       MNIOPHN
    So, Would you like to tell me how to do?
    Thanks&Regards,
    Kerry

    Hi Kerry,
    You can use the attributes of class: cl_abap_char_utilities
    If it_longtext is the table which contains your longtext data.
    DATA:  c_new value cl_abap_char_utilities=>newline,
                v_ltxt type string.
    loop at it_longtexts into wa_longtexts.
      concatenate v_ltxt wa_longtexts-text_line  into v_ltxt.
    endloop.
    refresh it_longtexts[].
    split v_ltxt at c_new into it_lontexts.
    Regards,
    Swarna Munukoti
    Edited by: Swarna Munukoti on Dec 4, 2009 11:44 AM

  • How to vertically center text in table cell?

    How do I get text to center vertically in a cell?

    It centres all the text, no matter how many lines. I test the solution.
    What have you done? Explain what you are getting and exactly what it is you have done and the result you wanted. We can't see your screen.
    Peter

Maybe you are looking for

  • Can I use a cable to connect my macbook pro to a tv?

    I have a macbook pro (late 2008) with intel GMA x3100 video adapter.  I'd like to get a cable to watch dvds on a tv using the mini display port.  I've found several mini DVI to HDMI cables and adapters but want to make sure that these will work prior

  • How to get each character in a string

    as in 'C' we use arrays to get each character of a string stored in array.how can we get each character of a string stored in a variable.

  • Raw Material  Cost Estimate

    Hi, I am trying to cost raw material. 1. I perform all the steps in product costing, assign condition type to origin group: PB00 cond type to PB00 origin group ZMAT cond type to ZMAT origin group this is because I want to see the breakout of the PB00

  • What operating system smartphone is compatible with Adobe Flash Player?

    What operating system smartphone is compatible with Adobe Flash Player?

  • Search groups with multiple rows into a sngle row

    Hey all I have a view similar to the one below what I am trying to do is get the projects that have been fully completed. Meaning all items in that order have been sent. If there is an assignment within that project that has only been partially compl