Export a spreadsheet as image (.jpg)

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
GustavoPrograma
Posts: 15
Joined: Fri Aug 15, 2014 3:51 pm

Export a spreadsheet as image (.jpg)

Post by GustavoPrograma »

Hello guys, you are ok?
I have a problem and I need your help to solve it.

I need export a spreadsheet in image format, for someone can see it in a smartphone.

I'm trying to use draw pages to save it in .jpg format... But it search something as a graphic... I need convert a range of cells in a image. (the exported image don't have nothing, is all white and must be a cell range in the image)

Here is my code:

Code: Select all

sub img

Dim oFilter
Dim args(1) as new com.sun.star.beans.PropertyValue
oFilter=CreateUnoService("com.sun.star.drawing.GraphicExportFilter")
oFilter.setSourceDocument(ThisComponent.drawPages(0))
args(0).Name = "URL"                 'Where the file will be saved
args(0).Value = "file:///c:/Users/Gustavo Boladão/Desktop/bola.JPG" 'The destination URL
args(1).Name = "image"           'What type of file
args(1).Value = "jpeg"         'The file type
oFilter.filter(args())

end sub 
Could you help me? Thanks a lot guys!
IT'S URGENT!
OpenOffice 2.4
User avatar
MrProgrammer
Moderator
Posts: 4895
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Export a spreadsheet as image (.jpg)

Post by MrProgrammer »

GustavoPrograma wrote:I need export a spreadsheet in image format, for someone can see it in a smartphone.
No need for an evil macro: File → Export as PDF.

If this answered your question please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
GustavoPrograma
Posts: 15
Joined: Fri Aug 15, 2014 3:51 pm

Re: Export a spreadsheet as image (.jpg)

Post by GustavoPrograma »

Ok, is a great idea but what can I do for don't export the last spreadsheet?
I have 6 spreadsheets (0 to 5)... What method can I use to export only 0 to 4 (Spreadsheet 1,2,3,4 and 5)
OpenOffice 2.4
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Export a spreadsheet as image (.jpg)

Post by Villeroy »

1) Define print ranges that do not include the unwanted sheets.
2) Turn off automatic calculation, delete unwanted sheets, export and close without saving.
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
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Export a spreadsheet as image (.jpg)

Post by John_Ha »

PrtScrn copies the PC screen to the clipboard (alt/PrtScrn copies the active window). Now paste it into an image editor and save as a PNG file.

Incidentally, never use JPG files for text as the lossy compression algorithm blurs the text edges and adds compression artefacts (the clue is in the P - it stands for Photographers!). PNG uses lossless compression and is ideal for graphics as opposed to photos (and the P now stands for Portable).
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Phillip
Posts: 102
Joined: Wed Jan 09, 2013 1:50 pm

Re: Export a spreadsheet as image (.jpg)

Post by Phillip »

If you just want to create a picture of part of a spreadsheet: Select, copy. Then paste into an Image editor like IrfanView and save it in whatever format you want.
Copy (Ctrl+C) again and then you can paste the image into another program.
I use this to copy part of a spreadsheet onto another - like the previous and next month in small type, under the larger current month for a monthly calendar.
Attachments
Sheet with pictures from other sheets.ods
(27.53 KiB) Downloaded 269 times
Open Office 4.1.11, Windows 7 Professional 64-bit
Post Reply