Hi Masood,
Converting table to text is indeed what can come to mind first but how would you ensure page location consistency ? You could have different cells heights that a regular leading wouldn’t reproduce. But maybe I am wrong.
Here is a script approach (given that we have a 3 columns tables as introduced).
Array.prototype.contains = function ( object )
{
var i = 0, n = this.length;
for ( i = 0 ; i < n ; i++ )
{
if ( this[i] === object )
{
return true;
}
}
return false;
}
var main = function() {
var t, rows, n, row, data = [], pg;
if ( !app.properties.activeDocument
|| app.selection.length!=1
|| !(app.selection[0] instanceof TextFrame )
|| !app.selection[0].parentStory.tables.length
) {
alert(“Please select a text frame with on table inside”);
return;
}
t = app.selection[0].parentStory.tables[0];
if ( app.selection[0].parentStory.overflows
|| t.cells.everyItem().overflows.contains (“true”) ) {
alert( “please fix overflow first”);
return;
}
if ( t.columns.length < 3 ) {
alert( “Table must count 3 columns”);
return;
}
rows = t.rows;
n = rows.length;
while ( n– ) {
row = rows[n];
pg = row.cells[0].insertionPoints[0].parentTextFrames[0].parentPage;
if ( row.rowType == RowTypes.BODY_ROW ) {
data[ data.length ] = [row.cells[0].contents, row.cells[2].contents, (pg? pg.name : “?” )];
}
}
makeCSV ( data );
alert(“OK” );
}
var makeCSV = function(data) {
var f = File ( Folder.desktop+”/index.txt” );
var n = data.length, sep = “”;
f.open(‘w’);
f.writeln ( “Product”+sep+”Price”+sep+”Page” );
while ( n– ) {
f.writeln( data[n].join(sep) );
}
f.close();
}
main();