[Calc, Python] Print selected sheets and ranges

Creating Extension - Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.

[Calc, Python] Print selected sheets and ranges

Postby Villeroy » Tue Jun 04, 2013 7:13 pm

2016-06-27: Credits to Andrew Davison, the author of “Java LibreOffice Programming” (JLOP) who pointed me to a viable solution which is able to print selected sheets. This is not a solution for selected ranges yet. See attached spreadsheet document.
The Basic code specifies selected sheets by an array of indices, a boolean constant if the output should be printed to file or printer device together with a file name and a printer name for the respective output.
Code: Select all   Expand viewCollapse view
REM we are going to print the first and third sheet:
aSheetNums = Array(0, 2)

REM Print to file
Const bPrintToFile = True
sOutFile = ThisComponent.URL & ".pdf"

REM if not to file, specify printer name
Const cPrinterName = "PDF"
Attachments
PrintSheets.ods
3 sheets and a macro to print sheet #1 and sheet #2 only.
(30.71 KiB) Downloaded 93 times
Last edited by Villeroy on Mon Jun 27, 2016 11:25 pm, edited 4 times in total.
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: 24652
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Calc, Python] Print selected sheets and ranges

Postby RichieRH » Sun Feb 08, 2015 5:50 am

Nice.........Tks
Debian 8 Jessie
Linux Mint 17.3 XFCE
Country : Indonesia
Learning is a need
User avatar
RichieRH
 
Posts: 34
Joined: Sun Oct 19, 2014 6:16 pm

Re: [Calc, Python] Print selected sheets and ranges

Postby RichieRH » Thu Feb 12, 2015 12:44 pm

How do I used it?Any examples would be appreciate ...
Debian 8 Jessie
Linux Mint 17.3 XFCE
Country : Indonesia
Learning is a need
User avatar
RichieRH
 
Posts: 34
Joined: Sun Oct 19, 2014 6:16 pm


Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 2 guests