You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@openoffice.apache.org by IMMO WETZEL <IM...@adtran.com> on 2014/06/26 09:25:49 UTC

how to find the current row in a table in writer to delete this one

I'm working on a huge document with a lot of tables and images and so on.
Now I have to modify a table and to delete empty/unused rows. Every Row has an unique text string in the first cell.

How can I delete these rows without knowing the exact position of this row.

Are the any way to fill the removebyindex function with data ?

I guess there must be something like

-          Search the text

-          Detect the row number

-          Remove the row
But I couldn't find it


Immo


Re: how to find the current row in a table in writer to delete this one

Posted by Bernard Marcelly <ma...@club-internet.fr>.
Hi,
I suppose :
- you are working on a Writer document
- your tables are simple, regularly squared : no cell merged, no split cells.

This example works on a table, explores lines from bottom to top, deletes lines 
where the first cell has a specific string.

REM  *****  BASIC  ***
Dim aTable As Object, allRows As Object, firstCell As Object
Dim y As Long

aTable = ThisComponent.getTextTables.getByIndex(0)
allRows = aTable.getRows
for y = allRows.getCount -1 to 0 step -1
   firstCell = aTable.getCellByPosition(0,y)
   if firstCell.String = "dd"  then
     allRows.removeByIndex(y, 1)
   end if
next

Questions like this are more easily answered in the community forum 
<https://forum.openoffice.org/en/forum/>

Regards
   Bernard

Message de IMMO WETZEL  date 2014-06-26 09:25 :
> I'm working on a huge document with a lot of tables and images and so on.
> Now I have to modify a table and to delete empty/unused rows. Every Row has an unique text string in the first cell.
>
> How can I delete these rows without knowing the exact position of this row.
>
> Are the any way to fill the removebyindex function with data ?
>
> I guess there must be something like
>
> -          Search the text
>
> -          Detect the row number
>
> -          Remove the row
> But I couldn't find it
>
>
> Immo
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


Re: how to find the current row in a table in writer to delete this one

Posted by Regina Henschel <rb...@t-online.de>.
Hi Andrew,

Andrew Douglas Pitonyak schrieb:
> On 06/26/2014 03:25 AM, IMMO WETZEL wrote:
>> I'm working on a huge document with a lot of tables and images and so on.
>> Now I have to modify a table and to delete empty/unused rows. Every
>> Row has an unique text string in the first cell.
>>
>> How can I delete these rows without knowing the exact position of this
>> row.
>>
>> Are the any way to fill the removebyindex function with data ?
>>
>> I guess there must be something like
>>
>> -          Search the text
>>
>> -          Detect the row number
>>
>> -          Remove the row
>> But I couldn't find it
>>
>>
>> Immo
>>
>>
>
> Although I don't have an answer off hand....
>
> The view cursor has a TextTable property and a Cell property that tell
> you the current text table and the current cell. The cell object has a
> property named CellName which may be of assistance.
>

Yes, that way I have it done for to insert a row before the current 
cursor position.

CellName is e.g. "B3" or "AA24". In the loop I extract the number from 
this string.

Sub InsertRowBefore
dim oCurrentController as variant
oCurrentController = ThisComponent.getCurrentController()
dim oViewCursor as variant
oViewCursor =oCurrentController.getViewCursor()
dim oActualWriterTable as variant
oActualWriterTable = oViewCursor.TextTable
if NOT(isEmpty(oActualWriterTable)) then
	dim oCell as variant
	oCell = oViewCursor.Cell
	dim oCellName as string
	oCellName = oCell.CellName
	dim nCount as long
	nCount =len(oCellName)
	dim sTeil as string
	do
		nCount = nCount-1
		sTeil = right(oCellName,nCount)
	loop until isNumeric(sTeil)
	dim nRow as long: nRow = CLng(sTeil)
	oActualWriterTable.Rows.insertByIndex(nRow-1,1)
endif
End Sub

Kind regards
Regina


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


Re: how to find the current row in a table in writer to delete this one

Posted by Andrew Douglas Pitonyak <an...@pitonyak.org>.
On 06/26/2014 03:25 AM, IMMO WETZEL wrote:
> I'm working on a huge document with a lot of tables and images and so on.
> Now I have to modify a table and to delete empty/unused rows. Every Row has an unique text string in the first cell.
>
> How can I delete these rows without knowing the exact position of this row.
>
> Are the any way to fill the removebyindex function with data ?
>
> I guess there must be something like
>
> -          Search the text
>
> -          Detect the row number
>
> -          Remove the row
> But I couldn't find it
>
>
> Immo
>
>

Although I don't have an answer off hand....

The view cursor has a TextTable property and a Cell property that tell 
you the current text table and the current cell. The cell object has a 
property named CellName which may be of assistance.

-- 
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org