[Solved] Transform CellAddress to cell name using Java

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
Lookris
Posts: 10
Joined: Mon May 28, 2018 7:14 pm

[Solved] Transform CellAddress to cell name using Java

Post by Lookris »

Is there a way to get human readable version of CellAddress struct? I desperately want to transform Sheet = 1, Column = 1, Row = 1 into simple and sleek A1 (or even 1.A1)
Last edited by RoryOF on Mon May 28, 2018 9:11 pm, edited 2 times in total.
Reason: Added green tick [RoryOF, Moderator]
LibreOffice 6.0 on Linux Mint 18.3 Sylvia
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Transform CellAddress to cell name using Java

Post by Villeroy »

Get the cell object and then property AbsoluteName.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Transform CellAddress to cell name using Java

Post by FJCC »

A cell object that has a CellAddress will also have an AbsoluteName like $Sheet1.$A$1. Can you use that?

By the way, when CellAddress.Column = 1, that is column B and when CellAddress.Row = 1 that is row 2
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Lookris
Posts: 10
Joined: Mon May 28, 2018 7:14 pm

Re: Transform CellAddress to cell name using Java

Post by Lookris »

Yeah, a little string manipulation, and this will do the trick. Thank you
LibreOffice 6.0 on Linux Mint 18.3 Sylvia
Lookris
Posts: 10
Joined: Mon May 28, 2018 7:14 pm

Re: [Solved] Transform CellAddress to cell name using Java

Post by Lookris »

Any way to do the same with ComplexReference? The straightforward way of doing something like splitting reference in two, then getting cells by their addresses, then getting AbsoluteName of each of them, THEN handcrafting `A1:A3` string with `.split()`s and `.removeAll()`s seems cumbersome to say the least
LibreOffice 6.0 on Linux Mint 18.3 Sylvia
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Transform CellAddress to cell name using Java

Post by Villeroy »

You have to install the MRI extension.
AbsoluteName is a property of a cell range.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply