Question

I have a LibreOffice 3 spreadsheet (on Ubuntu 11.04) with a column of hundreds of hyperlinks which simply display as 'Link'.

I need to convert these to just plain text, or at worse hyperlinks which display the hyperlink rather than the text 'Link'. Is there a function which will do this, or perhaps a method that will do it across the entire spreadsheet?

Was it helpful?

Solution

You can use a macro.

The only one I've tested is this one.

If you haven't had experience with macros, here are the steps involved:

  1. Copy the macro provided at that link.
  2. Press ALT + F11 to open your macros organizer.
  3. Under "My Macros" select "Module 1" and click on "Edit"
  4. Paste the macro code that you copied.
  5. Save and close your macro

Now, you have access to a macro titled "CELL_URL" which you can use as follows:

Assuming that your links start in "CELL A1" on "SHEET 1", I recommend you go to a new sheet, and in the first cell, enter: =CELL_URL("SHEET 1",ROW(),COLUMN()). Then, you can drag that formula according to the dimensions of your data.

Or, another example, assuming that you have a single column of 20 links, starting from "CELL B5" on "SHEET 1", and that you want the URL to be in the column next to it (thus, starting from "CELL C5"), in "CELL C5", enter the formula as follows: =CELL_URL("SHEET 1", ROW(), COLUMN()-1). Note the -1. That tells the function to extract the URL from the cell from one column less than the current position.Then, drag the formula from "CELL C5" to "CELL C24", where your links end.


Update:

The URL doesn't seem to be resolving. Fortunately, there's the WayBack Machine: http://web.archive.org/web/20120713222701/http://www.oooforum.org/forum/viewtopic.phtml?t=32909

I've also posted the macro as a Gist: https://gist.github.com/mrdwab/14c9e81dfbc867351bd3

As can be noted in the comments, you may need to change "SHEET 1" to "Sheet1" when using the CELL_URL() function.

OTHER TIPS

Here is another way, using Unix command line tools - and bypassing Calc altogether.

First of all, unpack the .ods you have as a zip; example:

$ cd /tmp
$ mkdir my_ods_unpack
$ cd my_ods_unpack
$ unzip /path/to/my.ods

Once unzipped, you can look in ./content.xml, and realize all the URLs are enclosed in double quotes "; thus we can write the following grep line:

$ grep -ro 'http[^"]*' .
./meta.xml:http://www.w3.org/1999/xlink
./meta.xml:http://purl.org/dc/elements/1.1/
./meta.xml:http://openoffice.org/2004/office
...

... and once it gets to ./content.xml, you should start seeing the URLs that have been put in the document.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top