[Solved] Unable to fit images to cells

Discuss the spreadsheet application
Post Reply
sdobbie
Posts: 1
Joined: Wed Feb 14, 2024 11:34 pm

[Solved] Unable to fit images to cells

Post by sdobbie »

Hi all, I am having an issue where the anchor point for an image in the spreadsheet moves up to the next cell unless I scale the image down and place it at the bottom of the cell, leaving a gap at the top. Any ways to get the image to fill the cell while keeping the anchor point in the same cell?
Clipboard02.jpg
Clipboard02.jpg (11.75 KiB) Viewed 870 times
I am using the latest version of open office on windows 10x64, had to put vista as no matter what I typed in my signature, it wouldn't let me sign up.
 Edit: I updated your signature for you -- MrProgrammer, forum moderator  
Last edited by MrProgrammer on Fri Feb 23, 2024 10:28 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] Solutions provided; no response from sdobbie -- MrProgrammer, forum moderator
OpenOffice 4.1.15 on Windows 10
FJCC
Moderator
Posts: 9283
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Unable to fit images to cells

Post by FJCC »

If I click on a cell and select the menu item Insert -> Picture -> From File, I think I get what you want. Is that what you are doing?
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.
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Unable to fit images to cells

Post by Zizi64 »

You can align an image PRECISELY to a cell by some macros. (You must realign them when the cell size changed.)

Similar topic:
viewtopic.php?t=34544

Code: Select all

REM  *****  BASIC  *****
option explicit 


Sub fitGraphics()

 Dim oDoc As Object
 Dim oSheet As Object
 Dim oShape as Object
 Dim iCount As Integer
 Dim lCol, lRow as long
 Dim oSize As new com.sun.star.awt.Size
 Dim oPoint As new com.sun.star.awt.Point		
	
	oDoc = ThisComponent	
	oSheet = oDoc.CurrentController.ActiveSheet		
	iCount = oSheet.DrawPage.count		
	Do While iCount >= 1 
		oShape = oSheet.DrawPage(iCount - 1)
		if oShape.supportsService("com.sun.star.drawing.GraphicObjectShape") then
			oSize = oShape.getSize()			
			lCol = oShape.anchor.CellAddress.Column
			lRow = oShape.anchor.CellAddress.Row
			oSize.Height = oSheet.Rows(lRow).Height 
			oSize.Width = oSheet.Columns(lCol).Width			
			oShape.setSize(oSize)
			oShape.setPosition(oShape.anchor.Position)
		endif		
		iCount = iCount - 1
	Loop
	
End Sub
Align images.ods
(50.57 KiB) Downloaded 44 times
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Unable to fit images to cells

Post by Lupp »

Recent versions of LibreOffice Calc allow a setting >Anchor>To Cell (resize with cell) for any shape. For shapes anchored to cells (instead of "To Sheet") there is also a tool named Fit to Cell Size available from the context menu.
Having used the tool, and having set the anchor type, the shape will adapt automatically to changes of the cell size (not regarding the aspect ratio).
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply