Die folgenden Beispiele zeigen Programm-Code zur makrogesteuerten Erzeugung eines Balkenplans mit Termsoft GanttAssistant™. Sie erhalten detaillierte Hilfe zu jedem Parameter und zu jeder Methode von Termsoft GanttAssistant™ im Kapitel Termsoft.XLS ff.
|
Wenn Sie Visual Studio.NET als Entwicklungsumgebung verwenden, können Sie Hilfe zu Parametern und Methoden direkt aus Visual Studio heraus aufrufen, sofern Sie beim Termsoft GanttAssistant™-Setup die Hilfe für Visual Studio zur Installation ausgewählt haben. Wiederholen Sie ggf. das Setup mit dieser Option. Auch wenn das Objektmodell von Termsoft GanttAssistant™ sehr klein und übersichtlich ist, machen Sie zur Zeitersparnis bei der Suche nach Hilfe zu einzelnen Parametern und Methoden von der integrierten Suchfunktion Gebrauch. |
Visual Basic (MS Excel-Makro)
Dim GA As Object ' ------ GanttAssistant-Instanz erzeugen... Set GA = CreateObject("Termsoft.XLS.GanttAssistant") ' ------ Das aktuelle Excel-Application-Objekt an die GanttAssistant-Instanz übergeben, ' ------ damit dieses für die Ausgabe des Balkenplans verwendet wird. Das Excel-Application-Objekt ' ------ wird außerdem als Eigentümer der GanttAssistant-Instanz angemeldet. Call GA.DefineOwnerObject(Application) ' ------ Beschriftung des Kopfbereichs des Gantt-Plans... GA.GanttChartCaption = "Projekt " & "Modul Alpha" & " / Grobablauf" GA.ChartDescriptionField1 = "Ersteller:" GA.ChartDescriptionValue1 = "Dr. Meyer" GA.ChartDescriptionField2 = "Abteilung:" GA.ChartDescriptionValue2 = "Zentrales Projektbüro" GA.ChartDescriptionField3 = "Firma:" GA.ChartDescriptionValue3 = "Success Company AG" GA.ChartDescriptionField4 = "Projekt:" GA.ChartDescriptionValue4 = "Modul Alpha" ' ------ Benennung der Plantypen. ' ------ Es sollen hier pro Vorgang drei Balken gezeichnet werden. Daher die Plantypen: Plan, Soll, Ist. GA.BarDataType1Name = "Plan" GA.BarDataType2Name = "Soll" GA.BarDataType3Name = "Ist" ' ------ Es sollen die Balken der drei Plantypen angezeigt werden... GA.ShowBarDataType1 = True GA.ShowBarDataType2 = True GA.ShowBarDataType3 = True GA.ShowBarDataType4 = False ' ------ Festlegen der Balkenfarben der einzelnen Plantypen. Dazu werden die Excel-Color-Indizes ' ------ verwendet... GA.ColorIndexPlanType1 = 8 GA.ColorIndexPlanType2 = 35 GA.ColorIndexPlanType3 = 40 GA.ColorIndexMilestone = 16 ' ------ Die Zeit-Skala soll automatisch gewählt werden... GA.TimeScale = 6 '1: Tag, 2: Woche, 3: Monat, 6: Automatische Auswahl durch System ' ------ Festlegen der Skalenbeschriftung... GA.ScaleDayCaption = "Tages-Skala" GA.ScaleWeekCaption = "Wochen-Skala" GA.ScaleMonthCaption = "Monats-Skala" ' ------ Festlegen der Spaltenüberschriften im Chart... GA.TaskNameColumnCaption = "Name des VG" GA.TaskTitleColumnCaption = "Titel des VG" GA.TaskCompletionColumnCaption = "Fertigst." GA.TaskStartDateColumnCaption = "Anfang" GA.TaskFinishDateColumnCaption = "Ende" GA.TaskLeadColumnCaption = "Chef des VG" GA.TaskWorkColumnCaption = "Aufwand (h)" GA.TaskSequenceNumberColumnCaption = "lfd. Nr." GA.TaskBarDataTypeColumnCaption = "Plantyp des Balkens" ' ------ Übergabe der Vorgangsdaten. ' ------ Variablen erzeugen... '01: Name des Vorgangs Dim VG_Name As String '02: Kommentar zum Vorgang (wird in Excel als Zell-Kommentar gezeigt) Dim VG_Kommentar As String '03: Titel des Vorgangs Dim VG_Titel As String '04: Verantwortlicher Dim VG_Chef As String '05: Fertigstellungsgrad. Beliebiger Text ist als Eingabe möglich Dim VG_Fortschritt As String '06: Kommentar zum Fertigstellungsgrad (wird in Excel als Zell-Kommentar gezeigt) Dim VG_Fortschritt_Kommentar As String '07: Anfangstermin des Vorgangsbalkens zum Plantyp-1 (hier: "Plan") Dim VG_Plan_AT As Date '08: Endtermin des Vorgangsbalkens zum Plantyp-1 (hier: "Plan") Dim VG_Plan_ET As Date '09: Aufwand des Vorgangs zum Plantyp-1 (hier: "Plan") Dim VG_Plan_Aufwand As Integer '10: Anfangstermin des Vorgangsbalkens zum Plantyp-2 (hier: "Soll") Dim VG_Soll_AT As Date '11: Endtermin des Vorgangsbalkens zum Plantyp-2 (hier: "Soll") Dim VG_Soll_ET As Date '12: Aufwand des Vorgangs zum Plantyp-2 (hier: "Soll") Dim VG_Soll_Aufwand As Integer '13: Anfangstermin des Vorgangsbalkens zum Plantyp-3 (hier: "Ist") Dim VG_Ist_AT As Date '14: Endtermin des Vorgangsbalkens zum Plantyp-3 (hier: "Ist") Dim VG_Ist_ET As Date '15: Aufwand des Vorgangs zum Plantyp-3 (hier: "Ist") Dim VG_Ist_Aufwand As Integer '13: Anfangstermin des Vorgangsbalkens zum Plantyp-4 Dim Plantyp4_AT As Date '14: Endtermin des Vorgangsbalkens zum Plantyp-4 Dim Plantyp4_ET As Date '15: Aufwand des Vorgangs zum Plantyp-4 Dim Plantyp4_Aufwand As Integer '16: Zell-Kommentar zu einer (optionalen) Warnung zum Vorgang (z.B. die Begründung für Terminverzug). ' Der Vorgang wird im Chart markiert. Dim VG_Warnung_Kommentar As String ' ------ Variablen zuweisen... VG_Name = "Vorgang-1" VG_Kommentar = "Modul Alpha" VG_Titel = "Kick-Off-Meeting" VG_Chef = "Müller" VG_Fortschritt = "100%" VG_Fortschritt_Kommentar = Empty VG_Plan_AT = #4/28/2009 8:00:00 AM# VG_Plan_ET = #4/28/2009 4:00:00 PM# VG_Plan_Aufwand = -1 VG_Soll_AT = #4/28/2009 8:00:00 AM# VG_Soll_ET = #4/28/2009 4:00:00 PM# VG_Soll_Aufwand = 400 VG_Ist_AT = #4/28/2009 8:00:00 AM# VG_Ist_ET = #4/28/2009 4:00:00 PM# VG_Ist_Aufwand = 400 VG_Warnung_Kommentar = Empty ' ------ Vorgang übergeben... Call GA.AddTask(VG_Name, VG_Kommentar, VG_Titel, VG_Chef, VG_Fortschritt, VG_Fortschritt_Kommentar, _ VG_Plan_AT, VG_Plan_ET, VG_Plan_Aufwand, _ VG_Soll_AT, VG_Soll_ET, VG_Soll_Aufwand, _ VG_Ist_AT, VG_Ist_ET, VG_Ist_Aufwand, _ Plantyp4_AT, Plantyp4_ET, Plantyp4_Aufwand, _ VG_Warnung_Kommentar) ' ------ Variablen zuweisen... VG_Name = "Vorgang-2" VG_Kommentar = Empty VG_Titel = "Brainstorming" VG_Chef = "Meyer" VG_Fortschritt = "100%" VG_Fortschritt_Kommentar = Empty VG_Plan_AT = #4/29/2009 8:00:00 AM# VG_Plan_ET = #5/1/2009 4:00:00 PM# VG_Plan_Aufwand = -1 VG_Soll_AT = #4/29/2009 8:00:00 AM# VG_Soll_ET = #5/1/2009 4:00:00 PM# VG_Soll_Aufwand = 1200 VG_Ist_AT = #4/29/2009 8:00:00 AM# VG_Ist_ET = #5/1/2009 4:00:00 PM# VG_Ist_Aufwand = 1200 VG_Warnung_Kommentar = Empty ' ------ Vorgang übergeben... Call GA.AddTask(VG_Name, VG_Kommentar, VG_Titel, VG_Chef, VG_Fortschritt, VG_Fortschritt_Kommentar, _ VG_Plan_AT, VG_Plan_ET, VG_Plan_Aufwand, _ VG_Soll_AT, VG_Soll_ET, VG_Soll_Aufwand, _ VG_Ist_AT, VG_Ist_ET, VG_Ist_Aufwand, _ Plantyp4_AT, Plantyp4_ET, Plantyp4_Aufwand, _ VG_Warnung_Kommentar) ' ------ Der Balkenplan soll den Button zum Öffnen des Datendialogs im Fußbereich zeigen... GA.ShowDataButton = True ' ------ Balkenplan zeichnen... Call GA.Show
C# (WinForms-Applikation)
using System; using System.Text; using System.Windows.Forms; using Termsoft.XLS; namespace Gantt_CSharp_Demo { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private GanttAssistant ga = null; private void button1_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; // GanttAssistant-Instanz erzeugen... this.ga = new GanttAssistant(); // WICHTIG!!! Referenz auf das aktuelle WinForm übergeben... object o = this; // "this" repräsentiert das Formular! this.ga.DefineOwnerObject(ref o); this.ga.BarDataType1Name = "Plan optimistisch"; this.ga.BarDataType2Name = "Soll"; this.ga.BarDataType3Name = "Ist"; this.ga.BarDataType4Name = "Plan pessimistisch"; // 3 Balken erzeugen... for (int i = 0; i < 3; i++) { this.ga.AddTask("Vorgang-" + i.ToString("00000"), null, "Titel-" + i.ToString("00000"), "Meyer", "10%", null, new DateTime(2009, 09, 10).AddDays(2 * i), new DateTime(2009, 09, 12).AddDays(2 * i), 20, new DateTime(2009, 09, 10).AddDays(2 * i), new DateTime(2009, 09, 12).AddDays(2 * i), 20, new DateTime(2009, 09, 10).AddDays(2 * i), new DateTime(2009, 09, 11).AddDays(2 * i), 10, new DateTime(2009, 09, 10).AddDays(2 * i), new DateTime(2009, 09, 15).AddDays(2 * i), 50, null); } // Plan anzeigen. this.ga.Show(); this.Cursor = Cursors.Default; } private void button2_Click(object sender, EventArgs e) { if (this.ga == null) { MessageBox.Show("Bitte zuerst einen Balkenplan erzeugen!"); return; } // Den Datendialog der aktuellen GanttAssistant-Instanz öffnen... this.Cursor = Cursors.WaitCursor; this.ga.ShowDataDialog(); this.Cursor = Cursors.Default; } } }