Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[C#] In Excel Datei mit .ADO Beschreiben

Empfohlene Antworten

Veröffentlicht

Hallo

Folgendes Problem:

Ich Möchte in eine Excel Datei an einer Bestimmten Possition "A2:A2"

einen Wert Schreiben und die Datei Speichern.

Das ganze wird mit C# programmiert. Das Auslesen hat wunderbar gekappt das Schreiben Funktioniert kein bisschen. Die Open Funktion Funktioniert da ich ja auchauslesen kann.

Die Übergabeparameter strExcelSheet, strExcelRange, strWriteText sind auch okay !

Oder kann es so überhaupt nicht Funktionieren, verstehe ich das Prinzip Völlig Falsch ?

Die Hauptfunktion ist die WriteExcelRange(...) diese Wird im Main Programm aufgerufen !

//*******************************************************************

private void OpenConnectionToExcelFile( string strFilePath)

{

//String Vorbereitung

string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +

@"Data Source=" +strFilePath+ ";" +

"Extended Properties=" + Convert.ToChar(34).ToString() +

"Excel 8.0;" + @"HDR=Yes;IMEX=1" + Convert.ToChar(34).ToString();

//OleDbConnection Instanz Verbindungsstring übergeben

objConn.ConnectionString = sConnectionString;

//Verbindung zur ausgewählten Excel Datei öffnen

objConn.Open();

}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//*******************************************************************

private void WriteRangeFromOpenExcelFile (string strExcelSheet,string strExcelRange,string strWriteText)

{

objCmd.Connection = objConn;

objCmd.CommandText = "UPDATE [" + strExcelSheet + "$] SET (" + strExcelRange +" )= ' " + strExcelWrite + " ' ";

}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//********************************************************************

public void WriteExcelRange(string strFilePath,string strExcelSheet, string strExcelRange,string strWriteText)

{

this.OpenConnectionToExcelFile(strFilePath); //Excel Verbindung Aufbauen

this.WriteRangeFromOpenExcelFile(strExcelSheet,strExcelRange,strWriteText); //Excel Auslesen

objAdapter.UpdateCommand = objCmd;

objAdapter.UpdateCommand.Parameters.Add("test",OleDbType.VarChar,100,"test");

//objAdapter.InsertCommand.Parameters.Add("Z4S1",OleDbType.VarChar,100,"Z4S1");

objConn.Close(); //Excel Verbindung Schliessen

}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Gruß Nokinger

falls es jemals jemanden interessieren sollte

noch zur info folgender link

http://support.microsoft.com/default.aspx?scid=kb;EN-US;316934

also nachdem ich es die commandtext anweisung wie folgt versucht habe:

objcmd.commandtext = "insert into [Tabelle$a2:a2] set F1='wurstbrot'";

und dies immer noch nicht funktioniert hat, wobei ich sagen muss das die exception sich nicht mehr auf falsche sql anweisung bezog sondern auf schreibrechte.

wie auch immer hab dies nun endlich mit ne access base gemacht damit hat das schwap schwip hingehauen so schnell konnt ich gar nicht kucken wie das getutet hat.

Nokinger

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.