10-31-2023 01:56 AM
Hi,
Is there a way to hide a work sheet in a report template without deleting the sheet?
Template consist of 22 pages, based on condition, few pages need to be hidden before exporting to pdf file.
Ex: if type = "Engine" then need to export to PDF file with all pages except page no 5, 7, 14.
if type = "Non-Engine" then need to export to PDF file with all pages except 14, 18, 20
regards,
Durai
11-01-2023 10:20 AM
Why not delete the pages, save as pdf, then clear the template and reload it? Only the right pages will be exported and the template will stay the same
11-13-2023 09:34 AM
Hello Durai26,
You can use the ExportToPDF function of the sheet object, which has a second parameter that specifies whether the page should be attached to an existing PDF file or create a new PDF file. Set False for the first page to be exported and True for all other pages. This will give you a PDF that only contains the desired pages.
Here an example:
dim no_export : set no_export = CreateObject("Scripting.Dictionary")
call no_export.Add(5, 5)
call no_export.Add(7, 7)
call no_export.Add(14, 14)
dim sheet, append
append = false
for each sheet in Report.Sheets
  if not no_export.Exists(sheet.Index) then
    call sheet.ExportToPDF(CurrentScriptPath & "Engine", append)
    append = true
  end if
next