Export a spreadsheet as image (.jpg)

Creating a macro - Writing a Script - Using the API

Export a spreadsheet as image (.jpg)

Postby GustavoPrograma » Tue Sep 23, 2014 9:50 pm

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   Expand viewCollapse view
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
GustavoPrograma
 
Posts: 15
Joined: Fri Aug 15, 2014 3:51 pm

Re: Export a spreadsheet as image (.jpg)

Postby MrProgrammer » Tue Sep 30, 2014 5:47 pm

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.5 Build 9789 on MacOS 10.11.6.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Moderator
 
Posts: 3739
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Export a spreadsheet as image (.jpg)

Postby GustavoPrograma » Tue Sep 30, 2014 6:45 pm

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
GustavoPrograma
 
Posts: 15
Joined: Fri Aug 15, 2014 3:51 pm

Re: Export a spreadsheet as image (.jpg)

Postby Villeroy » Tue Sep 30, 2014 8:05 pm

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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26856
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Export a spreadsheet as image (.jpg)

Postby John_Ha » Wed Oct 01, 2014 4:20 pm

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).
AOO 4.1.6, Windows 7 Home 64 bit

See the Writer Manual, the Writer FAQ, the Writer Tutorials and the Writer guide.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 6649
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Export a spreadsheet as image (.jpg)

Postby Phillip » Tue Mar 12, 2019 9:17 pm

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 33 times
Open Office 4.1.5, Windows 7 Professional 64-bit
Phillip
 
Posts: 81
Joined: Wed Jan 09, 2013 1:50 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 7 guests