Edit All Cells In All Tables

Hello,
This is my first post, but I have been working with InDesign scripting for a while, and am pretty fluent in Javascript.
My scenario is, I have a document with about 1,000 pages. On each page is a table with approximately 100 cells, 10 rows and 10 columns with a description at the 0-space of each, followed by a floating point number (in the form of a percentage) in every other cell. What I need to do is format the text color of each percentage in each row depending on its value. For instance, in the first row, every percentage under 80.00% is red, while everything else needs to be green. All I need to do is color them based on their value. However, this value changes throughout the course of the 10 different rows.
I was able to make a script that would allow me to go over each cell in row 1 of every table on a single page, then iterate over all the other remaining pages in the same way before continuning onto row 2. This is a VERY long process, typically leading to a crash in any document over ~30 pages in length. Given that I want to run this over a gigantic 1,000+ page document (granted there is only 1 table per page), it becomes slightly impractical...
I'm simply curious if there is a way to run this in a more realistic manner. There has to be a quick way to iterate over each row, simply check the values, mark green or red and be done with it. My idea was to, perhaps, do every row in the table on one page and then go onto the next page, as opposed to row 1 over the entire document, followed by row 2, and so on and so forth? Perhaps that would help?
The code is FARRR too long to post here, but the rough process I have right now is the following:
1.) Setup variables to define the cells in each row:
     var allTables = app.activeDocument.stories.everyItem().tables.everyItem();
     var firstRowCells = allTables.rows[1].cells.everyItem().getElements();
         (There has to be a way to optimize that???)
2.) Call a bunch of for statements for the amount of rows I need to process (10) per table:
         for(var i = 0; i < firstRowCells.length; ++i)
               var a = parseFloat(firstRowCells[i].contents);
               if(a <= 80.00)
                     firstRowCells[i].texts[0].appliedCharacterStyle = "FAIL Red";
               } else if(a > 80.00){
                     firstRowCells[i].texts[0].appliedCharacterStyle = "PASS Green";
...all of this (about 10 for statements) results in a pretty rough crash. Anybody have a solution? Or at least an optimization tip?
Thanks,
-Chris

The goal is to make it as automated as possible, as these 1,000 page documents will be occurring about twice a week (as far as I know).
Here is what I'm looking at now with six rows programmed for a demo of my situation (figured I'd include a dummy first row for example):
The grep style hasn't changed, except varies from line to line to meet the goal criteria, but here is the code for the six rows. Again, all I need it to do is make the same code work in the same way on all tables in the document and we're golden. This seems like the right approach, though, as it is much faster than the parseFloat() call method. (Sorry about the hard to read code...for some reason it doesn't paste well into these forums??)
var cStyles = app.activeDocument.characterStyles;
                              if((cStyles.item("FAIL Red") != null) && (cStyles.item("PASS Green") != null))
                                        for(var i = 2; i < 6; ++i)
                                                  firstRowCells[i].appliedCellStyle = "80";
                                                  firstRowCells[6].appliedCellStyle = "Trend";
                                                  firstRowCells[7].appliedCellStyle = "80";
                                        pBar.hit();
                                        for(var i = 2; i < 6; ++i)
                                                  secondRowCells[i].appliedCellStyle = "80";
                                                  secondRowCells[6].appliedCellStyle = "Trend";
                                                  secondRowCells[7].appliedCellStyle = "80";
                                        pBar.hit();
                                        for(var i = 2; i < 6; ++i)
                                                  thirdRowCells[i].appliedCellStyle = "80";
                                                  thirdRowCells[6].appliedCellStyle = "Trend";
                                                  thirdRowCells[7].appliedCellStyle = "80";
                                        pBar.hit();
                                        for(var i = 2; i < 6; ++i)
                                                  fourthRowCells[i].appliedCellStyle = "40";
                                                  fourthRowCells[6].appliedCellStyle = "Trend";
                                                  fourthRowCells[7].appliedCellStyle = "40";
                                        pBar.hit();
                                        for(var i = 2; i < 6; ++i)
                                                  fifthRowCells[i].appliedCellStyle = "50";
                                                  fifthRowCells[6].appliedCellStyle = "Trend";
                                                  fifthRowCells[7].appliedCellStyle = "50";
                                        pBar.hit();
                                        for(var i = 2; i < 6; ++i)
                                                  sixthRowCells[i].appliedCellStyle = "30";
                                                  sixthRowCells[6].appliedCellStyle = "Trend";
                                                  sixthRowCells[7].appliedCellStyle = "30";
                                        pBar.hit();
                              } else {
                                        alert("Please setup character styles for PASS Green and FAIL Red, and re-run the program.");
Thanks again, Trevor, for all the help!!
-Chris
Edit: Actually...it didn't paste too too poorly after all once I clicked "Post"...hmmmm...

Similar Messages

  • How do you change/adjust border width for all the cells in a table created in Pages?

    How do you change/adjust border width for all the cells in a table created in Pages?
    Note- I am trying to figure out how to create and format tables in the latest version of the Pages app on an iPad air (iOS 8.1.1.1) . Creating tables, adding or removing borders for individual/all cells in a table seems straight forward. However the default border style seems to be a heavy black line. How do I change this?
    I found the option add or remove borders for all/ individual cells in a table, however I can't find any option within style/format dialogue screens for changing colour or line thickness for table cells. Likewise I can't find any clear instructions on how to do this in apple help pages or support website
    Btw- I'm assuming  it is possible to customize/adjust the colour & thickness of selected lines in a table created in this app (it's fairly easy to do this word processing apps like MS Word) please let me  know if this is not actually possible in Pages

    They know perfectly well what they took out of Pages '09.
    Well over 90 features.
    Do you think you posting feedback is going to remind them of what they did?
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Archive/trash Pages 5 and rate/review it in the App Store, then get back to work.
    Peter

  • Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.

    Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.
    when you copy n paste into a new table, all the cell sizes are changed.
    is there a way to put in a new table from your templates into an existing file, different to the standard very basic ones in insert table.
    I look forward to your answers.  Your help is very much appreciated.
    Also how do you search for question answers already written in this support area please.

    Hi Jason,
    In Numbers 3, you can select a whole table by clicking once in the table to make it active, then click once on the "bull's eye" at the top left.
    Now copy and paste. All formatting (and any cell content) is pasted intact. In Numbers 2.3 (Numbers '09) it is a little different for selecting a whole table. But I won't go into that unless you are using Numbers '09. Please reply.
    I don't like the look of the tables in Insert Table. I keep custom tables in My Templates. I have set Numbers > Preferences > General > For New Documents > Use template: (name of my favourite custom template)
    That opens when I launch Numbers, or ask for a new document (command n). Note that if you follow this preference setting, then Menu > File > New From Template Chooser (for another template) requires you to hold down the option key in that menu.
    Regards,
    Ian.
    Message was edited by: Yellowbox. All formatting (and any cell content) is pasted intact.

  • Change font size/type in all cells of table

    Hi,
    I cannot figure out how to change the font size/type in an existing table. There seems to be no way to select all cells and make a global change.
    I can select individual columns and rows, and change the font for these, but that is tedious.
    Anyone help?

    Click in one cell
    Select all
    cmd + T to get the Font panel then select the font and the size.
    Yvan KOENIG (from FRANCE jeudi 11 septembre 2008 21:15:51)

  • Get all rows from a table control

    Hi All,
    I have a table control with one column. What function should I use to retrieve all the rows ? Do I need to iterate row by row and read each row or is it possible to do it in one function ?
    Thanks,
    Kanu
    Solved!
    Go to Solution.

    Supposing vells in the column have all the same data type, you can retrieve the whole column with a single instruction:
    GetTableCellRangeVals (panel, control, VAL_TABLE_COLUMN_RANGE (1), array, VAL_COLUMN_MAJOR);
    The array passed must be large enough to retrieve all data. Alternatively, you may substitute the macro VAL_TABLE_COLUMN_RANGE with the appropriate MakeRect instruction.In case your table was dinamically built, you can obtain the nu,ìmber of rows using GetNumTableRows and dimension your array accordingly.
    The above macro is defined in userint.h together with some other useful macros that can be used to access data in a table.
    There are some precautions to take in case of string values or some cell type (ring, combo box, button...) that are described in the hell for the function.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How to delete all rows in all tables of a schema in Oracle?

    Hi all,
    I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
    may you help?
    Edited by: user8105261 on Nov 25, 2009 11:06 PM

    user8105261 wrote:
    Hi all,
    I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
    may you help?
    Edited by: user8105261 on Nov 25, 2009 11:06 PMA typical way to reset a schema (e.g. to recreate a schema on the test database) is totally different.
    1) Drop the user
    2) recreate the user including table scripts from
    2a) your version control system
    2b) from a export dumpfile using the "nodata" option while importing

  • I am unabel to select all rows in advance table using Select All option

    Hi all ,
    I am unable to select all the rows in advance table . Select All option in advance table selects all rows present in working page but doesnt select the rows which we get by clicking next button ... i am having a requirement to select all the rows with a single click on select all , is it possible ..
    Plz help
    Thanking you all

    Hi,
    I'm using an adf table but i don't want to have the "Select All" and "Select None" options above the table. Does someone know how i have to remove those links?
    Or is there indeed a solution to override the methodes of those links?
    Message was edited by:
    Alexander

  • Problem with select all cells in JTable

    Hi guys! I get some problem about selecting all cells in JTable. I tried to used two methods:
    1> table.selectAll()2> changeSelection(firstcell, lastcell,false,true)
    firstcell:[0,0], lastcell[rowcount-1,colcount-1]
    Result: only the first row selected when i use both methods.
    Note: i set up the selection model as following:
    this.dataSheet.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                    this.dataSheet.setCellSelectionEnabled(true);
                    this.dataSheet.setRowSelectionAllowed(true);
                    this.dataSheet.setColumnSelectionAllowed(true);Thanks !

    What selection properity should be changed in order to enable selectAll() method work properly? Is there Any constraints? Here is the TableModel I am using. And i set up selection mode use the following code:
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setCellSelectionEnabled(true);
    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(true);
    import java.util.Vector;
    import javax.swing.table.*;
    import javax.swing.JTable;
    public class DataSheetModel extends AbstractTableModel{
              private Vector data = new Vector();//Store data
              private Vector columnNames = new Vector();//Store head
              public DataSheetModel(){}
              public DataSheetModel(Vector headVector, Vector dataVector){
                   if(headVector != null) this.columnNames = headVector;
                   if(dataVector != null) this.data = dataVector;
              public int getColumnCount(){
                   return columnNames.size()+1;
              public int getRowCount(){
                   return data.size()+1;
              public String getColumnName(int col){
                   if(col==0) return "";
                   else return (String)columnNames.get(col-1);
              public Object getValueAt(int row, int col){
                   if(col==0) {
                        if(row != data.size()) return String.valueOf(row);
                        else return "*";
                   else{
                        if(row != data.size()){
                             Vector rowVector = (Vector)data.elementAt(row);
                             return rowVector.elementAt(col-1);
                        }else return null;
              public void setValueAt(Object value, int row, int col){
                   if(row != this.data.size()){
                        Vector rowVector = (Vector)data.elementAt(row);
                        rowVector.set(col-1,value);
                        this.data.set(row,rowVector);
                        this.fireTableDataChanged();
                   }else{
                        Vector rowVector = new Vector();
                        for(int i=0; i<this.getColumnCount()-1; i++) rowVector.add(null);
                        rowVector.set(col-1,value);
                        this.data.add(rowVector);
                        this.fireTableDataChanged();
              public Class getColumnClass(int c){
                   return getValueAt(0,c).getClass();
              public boolean isCellEditable(int row, int col){
                   if(col == 0) return false;
                   else return true;
              public void setDataVector(Vector head, Vector data){
                   if(head != null) this.columnNames = head;
                   if(data != null) this.data = data;
    }

  • Making first two digits of all cells increment one unit

    hi friends
    i am not expert in MS Excel & i need an urgent help.
    i had created a long excel sheet in Excel 2013 which i paste a part of that sheet here:
    the list is very long.
    now for some reasons, i have to edit this sheet so that in all cells, the first two digits from left increment one unit, as i have manually done that in the following figure. ( note: i don't want the color get read. i changed the color only to better view)
    the problem is that i don't do that manually because there are hundreds of cells & that takes long time.
    please introduce me all the methods which i can do that at once. (the format of all cells is text).
    really thanks in advanced

    Use this formula, starting in row 1 and copy down. Copy the result, use paste special to paste as Values over column A. Delete the formula.
    =TEXT(LEFT(A1,2)+1,"00")&MID(A1,3,99)
    cheers, teylyn
    Hi teylyn
    sorry for being late
    that's Great.thank you very very much, really helped me.
    best wishes for you
    regards

  • PLEASE HELP-JTable cell editor-change one cell, changes all cells of column

    for example i have 3 rows 4 columns, column 3 and 4 are dates. now if i change the date to a new value (eg for of column 3)
    for any row, and then i click on any other cell. All cell values ie all rows for that column are changed to that new value.
    ie it changed column 3 for all rows 1, 2 and 3 to that new value which i changed in only one cell of that column.
    PLEASE HELP me , tell me what change i make to the code to fix it ....
    this is my cell renderer for date
    class DateCellRenderer extends JbcDateTimeChooser implements TableCellRenderer {
      protected Border m_noFocusBorder;
      public DateCellRenderer() {
        super();
        setStylePattern(JbcDateTimeChooser.MEDIUM);
        m_noFocusBorder = new EmptyBorder(1, 2, 1, 2);
        setOpaque(true);
        setBorder(m_noFocusBorder);
      public Component getTableCellRendererComponent(JTable table,
       Object value, boolean isSelected, boolean hasFocus,
       int row, int column)
      if(value instanceof Date) {
          Date b = (Date)value;
          setDate(b);
        setFont(table.getFont());
        setBorder(hasFocus ? UIManager.getBorder(
          "Table.focusCellHighlightBorder") : m_noFocusBorder);
        return this;
    }I have this custom cell editor date
    class DateCellEditor extends AbstractCellEditor implements TableCellEditor {
      protected JbcDateTimeChooser editor;
      public DateCellEditor() {
        super();
        editor = new JbcDateTimeChooser();
        editor.setStylePattern(JbcDateTimeChooser.MEDIUM);
      public Object getCellEditorValue() {
        return editor.getDate();
      public Component getTableCellEditorComponent(JTable table,
       Object value, boolean isSelected, int row, int column)
        if(value instanceof Date) {
          editor.setDate((Date)value);
        return editor;
    }and this is how i defined in jtable
        lnnTableModel = new CellSiteLNNTableModel();
        lnnTable.setModel(lnnTableModel);
        lnnTableModel.addColumn("ABC");
        lnnTableModel.addColumn("DEF");
        lnnTableModel.addColumn("Date From");
        lnnTableModel.addColumn("Date To");
        for(int k = 0; k < lnnTableModel.getColumnCount(); k++) {
          TableColumn col = lnnTable.getColumn(lnnTableModel.getColumnName(k));
          TableCellRenderer renderer;
            DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer();
            renderer = textRenderer;
          TableCellEditor editor;
          JTextField textColumn = new JTextField();
          if((k == CellSiteLNN.DATE_FROM) || (k == CellSiteLNN.DATE_TO)) {
            editor = new DateCellEditor();  //  this is the cell editor
         renderer = new DateCellRenderer(); // this is the assigned cell renderer
          } else {
            editor = new DefaultCellEditor(textColumn);
          col.setCellRenderer(renderer);
          col.setCellEditor(editor);
        }

    table model is extended from AbstractTableModel
    and have these methods
    do you see anything wrong here.....
      public Object getValueAt(int row, int column) {
        Vector rowVector = (Vector)dataVector.elementAt(row);
        return rowVector.elementAt(column);
      public void setValueAt(Object aValue, int row, int column) {
        Vector rowVector = (Vector)dataVector.elementAt(row);
        rowVector.setElementAt(aValue, column);
        // generate notification
        fireTableChanged(new TableModelEvent(this, row, row, column));
      } // end method (setValueAt)

  • ORA-12983: cannot drop all columns in a table

    Hi,
    I am creating a table with two columns.
    I have modified a column as unused using ALTER statement.
    After that i have tried to drop the another column by using ALTER statement.
    But it throws an error ORA-12983: cannot drop all columns in a table.
    is it not possible to achieve this via ALTER statement?
    thanks

    is there any other way to find the name of the columns which have been marked as unused?Don't think so, and you would not be able to do much about. You won't be able to reference it, you won't be able to un-unuse it, and you would even be able to add a new column having same name.
    Why are you using SET UNUSED in the first place?
    Regards
    Peter
    Quoting myself:
    You won't be able to reference itMaybe not good enough:
    SQL> select column_name, data_type, segment_column_id
      from user_tab_cols
    where table_name = 'T';
    COLUMN_NAME                    DATA_TYPE   SEGMENT_COLUMN_ID
    SYS_C00001_11051618:28:14$     NUMBER                      1
    B                              NUMBER                      2
    SYS_C00003_11051618:28:14$     NUMBER                      3
    3 rows selected.
    select "SYS_C00003_11051618:28:14$" from t
    Error at line 1
    ORA-00904: "SYS_C00003_11051618:28:14$": invalid identifier
    SQL> alter table t drop column "SYS_C00001_11051618:28:14$";
    Table altered.
    SQL> select column_name, data_type, segment_column_id
      from user_tab_cols
    where table_name = 'T';
    COLUMN_NAME                    DATA_TYPE   SEGMENT_COLUMN_ID
    B                              NUMBER                      
    1 row selected.
    Note: Both columns "disappeared"  Thanks MichaelS
    Edited by: Peter on May 16, 2011 9:29 AM

  • Does UITableView have a callback for when it is done loading ALL cells?

    I find it very diffcult to change UIActivityIndicator on and off for data loading into a table. I set it on and then call "reload data" on my tableView and then turn it back off. I dont think that is correct, because reload data will return immediately, it doesnt block until al the data is loaded correct? So a better way it to check for a callback when all the cells are loaded?
    How are you guys doing this?

    The table isn't going to load all cells anyway.
    Say you have a 100-item table of which 6 cells are visible at a time. The table view will only use tableView:cellForRowAtIndexPath: to create 6 or 7 cells.
    Later on, if the user scrolls, the table view will call tableView:cellForRowAtIndexPath: some more, for the newly visible cells.
    If the table view held on to every cell once it had been loaded, more and more cells would gradually get allocated until all 100 cells were in existence and holding data. That would use up a lot of memory. (What if the table has 10,000 cells?)
    If the table view did the standard thing of calling \[release\] on a cell as soon as it didn't need it, memory wouldn't get used up but a lot of time would be wasted allocating and deallocating.
    So the table view has a list of "cells I have but don't really want". When they encourage you to call dequeueReusableCellWithIdentifier: in your tableView:cellForRowAtIndexPath: routine, they're effectively saying "when the table is asking you for a cell for a given table entry, ask the table if it's got any unwanted cells to give you, before you go off and allocate a new one".
    As far as your question is concerned, this means that the table never really finishes loading. It'll only load 6 or 7 cells at a time, and when the user scrolls, it'll load some more. Depending how you've written tableView:cellForRowAtIndexPath:, it may only ever have 6 or 7 cells in memory at a time.
    It all depends what you want. If you want your activity indicator to say "I am working on giving you a display but what you see on the screen isn't what you're ultimately going to get", then
    (1) Get each individual cell to start its filling-itself-with-visible-data process when you allocate/reuse the cell in tableView:cellForRowAtIndexPath:. Give the cell a unique visible appearance when you do this. When the load process is complete, get the cell to call setNeedsDisplay so that it can get repainted with the real data. The user's experience will be of a table that appears instantly, each cell with an activity indicator in it, and the activity indicators then disappear as soon as each cell finishes its work. It will look rather nice.
    Or (2) do much the same, but get each cell to increment a global "loads in process" counter when it is born/reborn, and decrement it when its data have arrived. Then use that global counter to control a single UIActivityIndicator.
    The key in both cases is for cell creation to be fast, and the actual loading of data to the cells (if it's slow) to be done separately.

  • Can VC print all data in a table?

    Hello!
      Can VC print all data in a table?
    Best Reagrds!
    csquare.

    I write it in this post:
    Re: Qusetion about Table View.
    It is possible, that you have to use the paging options.
    Regards,
    Marcel

  • Select all and deselect all in table control

    Hi experts,
        I want to make the select all and deselect all options in my table control.
    But i can't able to do that one. Kindly suggest me how to do that one.
    one more thing, if i select some rows in the table control, and press save it should be saved in some other table. how can i implement that one.
    Waiting for ur reply.
    Regards...
    Arun.

    Hi Arun,
    In the context node that you bind to the table, set the cardinality as 0..n and selection as 0..n. In the UI element Table, set the property selectionMode as 'multi'. Then a toggle button for select/deselect all will appear automatically in your table. You can see it in the top left corner.
    For your second question, after selecting the elemets and pressing 'save', in your event handler, do a get_selected_elements( ) on your node. This will return you a set of context elements. Loop through each element and do a get_static_attributes to get the rows. Then you can append these rows to another internal table and bind it to the context. Bind your second table to this node. If the two tables are in different views, the context nodes need to be present in the component controller and mapped to the views.
    Hope this helps.
    Regards
    Nithya

  • Incomplete Data on report (report does not show all records from the table)

    Hello,
    I have problem with CR XI, I'm running the same report on the same data with simple select all records from the table (no sorting, no grouping, no filters)
    Sometimes report shows me all records sometimes not. Mostly not all records on the report. When report incomplete sometimes it shows different number of records.
    I'm using CR XI runtime on Windows Server 2003
    Any help appreciated
    Thanks!

    Sorry Alexander. I missed the last line where you clearly say it is runtime.
    A few more questions:
    - Which CR SDK are you using? The Report Designer Component or the CR assemblies for .NET?
    - What is the exact version of CR you are using (from help | about)
    - What CR Service Pack are you on?
    And a troubleshooting suggestion:
    Since this works on some machines, it will be a good idea to compare all the runtime (both CR and non CR) being loaded on a working and non working machines.
    Download the modules utility from here:
    https://smpdl.sap-ag.de/~sapidp/012002523100006252802008E/modules.zip
    and follow the steps as described in this thread:
    https://forums.sdn.sap.com/click.jspa?searchID=18424085&messageID=6186767
    The download also includes instructions on how to use modules.
    Ludek

Maybe you are looking for

  • Mac book pro or windows..please help me.....

    Ok so I have a mac mini-.i wanna get a mac book pro-im gonna get the 7200 rpm drive..2gb ram.everything good with it as you vcan probably terll money is not an issue-but I c that the mac book pro only has a 2.16ghz processor-..now ive looked at windo

  • Some ABAP Questions?

    Can anyone give the answers to the following questions? 1. Can u tell me the sequence to triggering of INITIALIZATION , AT SELECTION-SCREEN, AT SELECTION-SCREEN OUTPUT &  AT SELECTION-SCREEN on field. 2. WHT is the diffrence between the two selection

  • Migration Path from Oracle8.0.4 to Oracle 9.2

    I need to migrate from Oracle 8.0.4 on Win NT to Oracle9.2 on Win 2000. I read the Oracle 9i Database Migration. Direct upgrade is not supported for Oracle 8.0.4. I need to complete the following 1.     Upgrade to release 8.0.6 using the instructions

  • Servlet Thread Pools for iPlanet WS 4.1

    We have iPlanet WS 4.1 SP 5, running on HP UX. Wanted to make sure servlets run fast, so set up servlet thread pool. Initial result was that even the startup servlet could not be loaded, got stack overflow. Reduced number of threads from 60 to 5. Now

  • Reconciliation: push updates from an OpenLDAP into OIM 11g

    Hello everyone , Is there in the latest OIM a "push" connector that would allow a reconciliation process (ie inward flow into OIM) starting from an OpenLDAP directory system? Thanks, Nikos