[Solved] Transform CellAddress to cell name using Java

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

[Solved] Transform CellAddress to cell name using Java

Postby Lookris » Mon May 28, 2018 7:17 pm

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
Lookris
 
Posts: 10
Joined: Mon May 28, 2018 7:14 pm

Re: Transform CellAddress to cell name using Java

Postby Villeroy » Mon May 28, 2018 8:07 pm

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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25467
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Transform CellAddress to cell name using Java

Postby FJCC » Mon May 28, 2018 8:08 pm

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
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6582
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Transform CellAddress to cell name using Java

Postby Lookris » Mon May 28, 2018 8:54 pm

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

Postby Lookris » Tue May 29, 2018 8:51 pm

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
Lookris
 
Posts: 10
Joined: Mon May 28, 2018 7:14 pm

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

Postby Villeroy » Tue May 29, 2018 10:34 pm

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 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25467
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests