How to Search and Replace in calc (ods) OpenOffice document

Java, C++, C#, Delphi, ??? - Using the UNO bridges

How to Search and Replace in calc (ods) OpenOffice document

Postby liste » Sun Nov 16, 2014 11:35 am

I am using Delphi Vcl and I want to use Search&Replace command in openoffice or libreoffice calc program. there is one example in here (http://stackoverflow.com/questions/7806 ... e-document ) but it is work in only odt file. I need for ods (calc) Find&Replace code for pascal or delphi
thanks for helps
OpenOffice 4.1 on Windows 7
liste
 
Posts: 2
Joined: Thu Nov 13, 2014 12:47 pm

Re: How to Search and Replace in calc (ods) OpenOffice docum

Postby karolus » Sun Nov 16, 2014 4:49 pm

Hallo

In Case of Calc-files the Method ..createReplaceDescriptor is available on Ranges like single sheets.

Code: Select all   Expand viewCollapse view
...
sheet : = StarDocument.Sheets.getByIndex(0);
FileReplace := sheet.CreateReplaceDescriptor;
....

sheet.ReplaceAll(FileReplace); 


Karolus
AOO4, Libreoffice - 5.1 … 5.3.2.2 on Linux Mint17
User avatar
karolus
Volunteer
 
Posts: 852
Joined: Sat Jul 02, 2011 9:47 am

Re: How to Search and Replace in calc (ods) OpenOffice docum

Postby Charlie Young » Sun Nov 16, 2014 5:34 pm

I would add that there is one poorly documented property of the SearchDescriptor which is specific to Calc:

SearchType (not included in API-reference ) integer - Determines if the search should be done in cell formulas (0) values (1) or notes (2). [Calc only]
Apache OpenOffice 4.1.1
Windows XP
User avatar
Charlie Young
Volunteer
 
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: How to Search and Replace in calc (ods) OpenOffice docum

Postby liste » Mon Nov 17, 2014 5:57 pm

hi Karolus

Thanks for answer. I try to test that code but there is no Create Replace Descriptor event on sheet object can you send me small sample?

karolus wrote:Hallo

In Case of Calc-files the Method ..createReplaceDescriptor is available on Ranges like single sheets.

Code: Select all   Expand viewCollapse view
...
sheet : = StarDocument.Sheets.getByIndex(0);
FileReplace := sheet.CreateReplaceDescriptor;
....

sheet.ReplaceAll(FileReplace);


Karolus
OpenOffice 4.1 on Windows 7
liste
 
Posts: 2
Joined: Thu Nov 13, 2014 12:47 pm

Re: How to Search and Replace in calc (ods) OpenOffice docum

Postby karolus » Mon Nov 17, 2014 6:07 pm

I'm only tell you what I've inspected with the Help ofMRI
Use the tool by yourself!
AOO4, Libreoffice - 5.1 … 5.3.2.2 on Linux Mint17
User avatar
karolus
Volunteer
 
Posts: 852
Joined: Sat Jul 02, 2011 9:47 am

Re: How to Search and Replace in calc (ods) OpenOffice docum

Postby Charlie Young » Mon Nov 17, 2014 9:12 pm

liste wrote:hi Karolus

Thanks for answer. I try to test that code but there is no Create Replace Descriptor event on sheet object can you send me small sample?

karolus wrote:Hallo

In Case of Calc-files the Method ..createReplaceDescriptor is available on Ranges like single sheets.

Code: Select all   Expand viewCollapse view
...
sheet : = StarDocument.Sheets.getByIndex(0);
FileReplace := sheet.CreateReplaceDescriptor;
....

sheet.ReplaceAll(FileReplace); 


Karolus


These things are case sensitive, try createReplaceDescriptor.
Apache OpenOffice 4.1.1
Windows XP
User avatar
Charlie Young
Volunteer
 
Posts: 1559
Joined: Fri May 14, 2010 1:07 am


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest