publish-reports.mac 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. Dim objRep As Object
  2. Dim objPDF as Object
  3. Dim configFile as String
  4. Dim publish As String
  5. Dim Debug As Integer
  6. Dim reportFile As String
  7. Dim exportFormat As String
  8. Dim layers As String
  9. Declare Sub ReportExport
  10. Sub Main ()
  11. Debug = 1
  12. Rem On Error Resume Next
  13. If Debug = 1 Then
  14. configFile = "C:\Projekte\Python\gctools\config\Reports.csv"
  15. publish = "C:\GAPS\Portal\daten"
  16. Else
  17. configFile = GetField(Command, 1, ",")
  18. publish = GetField(Command, 2, ",")
  19. End If
  20. Dim lineStr As String
  21. Dim reportFile As String
  22. Dim exportFormat As String
  23. Dim layers As String
  24. Open configFile For Input As #1
  25. Do While Not EOF(1)
  26. Line Input #1, lineStr
  27. reportFile = GetField(lineStr, 1, ";")
  28. exportFormat = GetField(lineStr, 2, ";")
  29. layers = GetField(lineStr, 3, ";")
  30. Print reportFile, exportFormat
  31. Call ReportExport
  32. Loop
  33. Close #1
  34. End Sub
  35. Sub ReportExport
  36. ' reportFile, exportFormat, layers as Parameters
  37. Dim exportFile as String
  38. Dim layer as String
  39. Dim layerInt as Integer
  40. Set objRep = CreateObject("CognosPowerPlay.Report")
  41. objRep.Open(folder + "\" + reportFile)
  42. exportFile = publish + "\" + Left(reportFile, Len(reportFile) -4)
  43. Select Case exportFormat
  44. Case "pdf"
  45. Set objPDF = objRep.PDFFile(exportFile + "_0.pdf", True)
  46. With objPDF
  47. .SaveEntireReport = True
  48. .AxisOnAllPages = True
  49. .ChartTitleOnAllPages = False
  50. .IncludeLegend = False
  51. End With
  52. objPDF.Save
  53. For i = 1 To 255
  54. layer = GetField(layers, i, ",")
  55. If layer = "" Then
  56. Exit For
  57. End If
  58. layerInt = Val(layer)
  59. If layerInt > objRep.Layers.Count Then
  60. Exit For
  61. End If
  62. Set objPDF = objRep.PDFFile(exportFile + "_" + layer + ".pdf", True)
  63. With objPDF
  64. .SetListOfLayersToSave objRep.Layers.Subset(layerInt, layerInt)
  65. .SetListOfRowsToSave objRep.Rows
  66. .SaveEntireReport = False
  67. .SaveAllCharts = False
  68. .AxisOnAllPages = True
  69. .ChartTitleOnAllPages = True
  70. .IncludeLegend = True
  71. End With
  72. objPDF.Save
  73. Next
  74. Case "asc"
  75. objRep.SaveAs exportFile, 3
  76. Case "xls"
  77. objRep.SaveAs exportFile, 4
  78. Case "ppx"
  79. objRep.SaveAs exportFile, 5
  80. Case Else
  81. objRep.Publish publish, False, True, True
  82. End Select
  83. objRep.Close
  84. Set objRep = Nothing
  85. End Sub