I have a calc document with 100 sheets. I want to generate 100 pdf with the name of each sheet, not one big pdf…
I managed to do it in Excel but not in Libre Office…
I managed to do it in Excel
How? Trying to export to PDF from Excel 2016, I only see an option to export to a single file (maybe limiting to active sheet or selection), not to a series of files…
Also: A sheetname may not be qualified as a filename.
If the most simple case concerning the names and the target folder (same as origional .ods) as well as the pdf options is assured, a macro for the task shouldn’t be too complicated. Study the famous texts by Andrew Pitonyak. The appropriate export filter should be calc_pdf_Export
.
See also (e.g.): [Solved] Macro to export to PDF [code added for] save as ods (View topic) • Apache OpenOffice Community Forum.
How did you “do it in Excel”?
how do I exports all sheets to single
pdf files with sheet name?
You can do it by your own macro.
It is not very difficult
Sub ExportAllSheetsToPDF
Rem Export options. Now they are minimal. To adjust the PDF format accurately,
Rem see https://wiki.openoffice.org/wiki/API/Tutorials/PDF_export
Dim ExportArgs(1) as new com.sun.star.beans.PropertyValue
Dim dataRange(0) as new com.sun.star.beans.PropertyValue
Dim oSheets As Variant, oSheet As Variant, oCursor As Variant
Dim sPath As String, sFileName As String
Dim i As Long
GlobalScope.BasicLibraries.LoadLibrary("Tools")
sFileName = ThisComponent.URL
If sFileName = "" Then Exit Sub ' This spreadsheet wasn't saved, so it hasn't path and name '
Rem Folder to store PDF - same as source file
sPath = ConvertFromURL(DirectoryNameoutofPath(sFileName,"/"))
If Right(sPath,1) <> GetPathSeparator() Then sPath = sPath + GetPathSeparator()
ExportArgs(0).Name = "FilterName"
ExportArgs(0).Value = "calc_pdf_Export"
ExportArgs(1).Name = "FilterData"
dataRange(0).Name = "Selection"
oSheets = ThisComponent.getSheets()
For i = 0 To oSheets.getCount()-1
oSheet = oSheets.getByIndex(i)
If oSheet.isVisible Then ' Skip hidden sheets '
Rem Export range with data only (skip first empty columns and rows)
oCursor = oSheet.createCursor()
oCursor.gotoStartOfUsedArea(False)
oCursor.gotoEndOfUsedArea(True)
Rem Set range with data as param of filter export
dataRange(0).Value = oCursor
ExportArgs(1).Value = dataRange()
Rem Create filename by sheet name
sFileName = sPath + oSheet.getName()+".pdf"
Rem Export
ThisComponent.StoreToURL(ConvertToURL(sFileName),ExportArgs())
EndIf
Next i
End Sub