Ask Your Question
0

how to get height of cell in basic program,get content [closed]

asked 2012-12-06 10:32:50 +0200

anonymous user

Anonymous

table have 2 columns. First column have 10 cells(1 cell =1 row) Second column have 2 cells,upper cell height 6 rows,bottom cell height 4 rows. How to get height upper and bottom cells in program on basic?, how to get content upper and bottom cells in program on basic?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-19 12:50:16.522252

3 Answers

Sort by » oldest newest most voted
0

answered 2012-12-06 12:23:55 +0200

JohnSUN gravatar image

updated 2012-12-11 09:04:46 +0200

May be so?

Sub getHeigthOfMergedCells
Dim oSheet As Variant
Dim nCount As Long
Dim oCellFormatRanges As Variant
Dim oEnum As Variant
Dim oCell As Variant
Dim oCursor As Variant
Dim aRes() As String

    oSheet = ThisComponent.getSheets().getByIndex(0)
    oCellFormatRanges = oSheet.getCellFormatRanges()
    oEnum = oCellFormatRanges.createEnumeration()
    Do While oEnum.hasMoreElements()
        oCell = oEnum.nextElement()
        If oCell.getIsMerged() Then
            nCount = UBound(aRes())+1
            ReDim Preserve aRes(nCount)
            oCursor = oSheet.createCursorByRange(oCell)
            oCursor.collapseToMergedArea()
            aRes(nCount) = "Cell " + oCell.AbsoluteName + "(" _
                + oCursor.AbsoluteName +") has Height=" _
                + oCursor.Size.Height + ", Width=" _
                + oCursor.Size.Width + " and Value='" _
                + oCell.getCellByPosition(0,0).getString() + "'"
        EndIf
    Loop
    If LBound(aRes()) > UBound(aRes()) Then
        MsgBox("No merged cells...")
    Else
        MsgBox("Found merged cells:"+Chr(10)+Join(aRes,Chr(10)))
    EndIf
End Sub
edit flag offensive delete link more
0

answered 2012-12-06 19:37:37 +0200

used gravatar image

thank you! I will test

edit flag offensive delete link more

Comments

NB. This Size (Height & Width) in 1/100 mm. If you want get it in "cells", use oCursor.getRows().getCount() and oCursor.getColumns().getCount()

JohnSUN gravatar imageJohnSUN ( 2012-12-07 09:17:26 +0200 )edit
0

answered 2012-12-10 19:58:05 +0200

used gravatar image

updated 2012-12-11 07:42:20 +0200

when test?get message oCell.getString() (-absent ????not found) Host archlinux x86_64,libreoffice 3.6.4-1 file.rtf http://exfile.ru/download/389963 read in Calc Thank you!

edit flag offensive delete link more

Comments

Yes, it was a typo. Not oCell.getString(), but oCell.getCellByPosition(0,0).getString(). Fixed. You have only 3 merged cells in this file ($R$39:$S$39,$R$40:$S$41 and $R$42:$S$42)

JohnSUN gravatar imageJohnSUN ( 2012-12-11 09:06:11 +0200 )edit

Question Tools

Stats

Asked: 2012-12-06 10:32:50 +0200

Seen: 585 times

Last updated: Dec 11 '12