Frage

Mein Chef hat mich gebeten, die corp Mantis Bugdatenbank nach Excel zu exportieren, aber er kann mir keinen Zugriff auf die SQL Server geben, und der Prozess muss automatisiert werden.

Das einzige, was ich verwenden kann, ist Excel (kein ODBC, kein manueller Export).

Also habe ich es geschafft, dies zu tun:

Dim webClient As Object
Dim i As Long, vFF As Long, oResp() As Byte
Dim vLocalFile As String
Dim username As String, password As String

username = "blahblah"
password = "blahblah"

Set webClient = CreateObject("WinHttp.WinHttpRequest.5.1")

// Opening the connection to the application with a POST, containing user, password, and "permanent login" checked

webClient.Open "POST", "http://10.202.157.40/mantisbt-1.1.6/login.php", False
webClient.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
webClient.send ("username=" & username & "&password=" & password & "&perm_login=on")

// Now I set the "project" to "All Projects" (as I want the view to display our 2200 bugs)

webClient.Open "POST", "http://10.202.157.40/mantisbt-1.1.6/set_project.php", False
webClient.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
webClient.send ("project_id=0")

// The problem is, the last query displays 624 bugs instead of 2200, but I noticed when I click on "Advanced Filters" it successfully show the 2200 bugs (tested under a web browser AND Excel : the ResponseText shows them)

webClient.Open "GET", "http://10.202.157.40/mantisbt-1.1.6/view_all_set.php?type=6&view_type=advanced", False
webClient.send

// And NOW I can download the CSV file... (and that's where something is wrong *)

webClient.Open "GET", "http://10.202.157.40/mantisbt-1.1.6/csv_export.php", False
webClient.send

oResp = webClient.responseBody

// Creating a file and then filling it...
vFF = FreeFile
vLocalFile = "_mantis_export.csv"
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF

// Freeing memory
Set webClient = Nothing

(*: cf den Code) Die Linie vor, die Response zeigte "2200 Fehler", so war alles in Ordnung bis zur letzten Abfrage (csv_export.php). Das Skript, wenn über einen Browser aufgerufen, zeigt genau die gleiche wie die Seite, die sie genannt (wenn die Seite 2 Bugs zeigte, wird die CSV 2 Fehler enthalten). Mit meinem 2200 Fehler im Internet Explorer / Firefox gezeigt, bringt die CSV mir 2200 Bugs. Aber in Excel, auch wenn die Response zeigt 2200 Bugs, bringt das CSV mir 624 Bugs ... Als ob ich nicht angerufen hatte die "Advanced Filter" Seite: (

Ich hoffe, jemand kann mir verstehen und helfen;)

Vielen Dank im Voraus,

David

War es hilfreich?

Lösung

Vielleicht wäre es einfacher für Sie, die SOAP-API verwenden? Der Einstiegspunkt ist unter http: //server/mantis/api/soap/mantisconnect.php .

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top