Autor Beitrag
estrella1410
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mi 28.05.08 10:05 
Hallo

ich habe da eine Frage und zwar habe ich ein Programm geschrieben in C#, welches Ping-Ergebnisse in eine Exceltabelle schreibt...mit anfangs und endzeitpunkt ...läuft auch alles brav nur möchte ich, da das Programm öffters läuft, dass die neuen Ergebnisse in der Tabelle unten angefügt werden....und dann natürlich gespeichert...also nich das dokument ersetzt wird sondern die Inhalte immer wieder unten angefügt werden...

Hat jemand eine Antwort für mich wie ich das mache??

Gruß,

Estrella
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mi 28.05.08 10:41 
Welche Klassen benutzt du denn bisher zum Schreiben der Datei :?:
estrella1410 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mi 28.05.08 10:52 
ALso ich poste einfach mal bissl code rein wie ich dit bisher mache...

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
            string path = "c:/serverping/Server.xls";

            Excel.Application aExcelApp;
            Excel.Workbook aWB;
            
            Excel.Worksheet aWS;
            aExcelApp = new Excel.Application();
            aWB = aExcelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
            aWS = (Excel.Worksheet)aWB.Worksheets[1];
            aWS.Name = "Ping-Überwachung";


            if (rückgabe != "")
                            {
                                Console.WriteLine(rückgabe);
                                aWS.Cells[i, 1] = dummy;
                                aWS.Cells[i, 2] = rückgabe;
                                i = i + 1;
                                aExcelApp.Visible = true;
                                //sw_log.WriteLine(rückgabe);
                                //sw_log.Flush();
                            }
                aWB.SaveAs(path, Excel.XlFileFormat.xlXMLSpreadsheet, nullnullfalsefalse, Excel.XlSaveAsAccessMode.xlNoChange, nullnullnullnullnull);



das is son bissl der code der sich auf meinen excel teil bezieht....

Moderiert von user profile iconChristian S.: Code- durch C#-Tags ersetzt
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mi 28.05.08 16:50 
Wenn ich das richtig sehe, kannst du doch mit Workbooks.Open ein vorhandenes Workbook öffnen.
estrella1410 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mo 02.06.08 06:34 
hmm..ja ist ja ne nette sachen mit dem "open" aber was hat das damit zutun dass ich in einer vorhandenen excel datei was anhängen möchte ??
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 02.06.08 10:26 
Ist doch offensichtlich, was es damit zu tun hat: Wenn Du etwas anhängen willst, musst Du es vorher öffnen.

Dann läufst Du nur noch die Zeilen durch und wenn Du eine findest, wo nix drin steht, schreibst Du ab dort rein.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
estrella1410 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mi 04.06.08 07:10 
oke klingt logisch und wie laufe ich die zeilen durch ...? sry aber was dieses excel gedöns angeht hab ich noch nicht wirklich nen 100%igen durchblick ...
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mi 04.06.08 09:34 
Und warum benutzt du dann Excel? Schreib doch alles in eine Text-Datei (am besten im CSV-Format), dann kannst du diese Datei auch von Excel öffnen.
estrella1410 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mi 04.06.08 12:56 
weil es langweilig ist nicht mal was neues auszuprobieren :)will ja dazulernen nicht stehen bleiben...
also habe nun alles schön reingeschrieben mein problem ist jetzt dass er am ende auf einen fehler läuft wegen dem speichern heißt soviel wie wenn ich das programm starte wird die exceltabelle erstellt und auch schön gespeichert ..beim 2ten durchlauf schreibt er auch hübsch rein aber speichert nicht direkt sondern fragt ab von wegn ob das dokument überschrieben werden soll...

wie kann ich das machen, dass er das nich fragt sondern einfach dann die neu hinzugefügten zeilen speichert...?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 04.06.08 14:04 
Ohne die Methoden zu kennen, würde ich sagen, dass Du dann Save anstatt SaveAs benutzen musst. Zumindest macht man das bei der Verwendung von Excel ja auch ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
estrella1410 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mi 04.06.08 14:18 
also das save habe ich auch benutzt weil ich mir das auch so gedacht habe also beim erstenmal speichern mach ichs per save as alle anderen male würde er in das einfache save springen aber irgendwie passt dem das nicht ;)
estrella1410 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46



BeitragVerfasst: Mo 09.06.08 07:16 
heeelp keiner noch ne idee ? :(