[wxWidget] Excel Ole Active Cell setzen



  • Moin Moin,

    ich bin der Verzweiflung nahe. Ich möchte mit wxWidgets eine aktive Zelle einer Excel-Liste ändern. Das Aufrufen und laden einer Tabelle klappt wunderbar, aber ich kann immer nur in A1 schreiben, ohne selber Zellen setzen zu können. Ich habe folgendes aus dem Internet ausprobiert, leider ohne Erfolg :

    wxVariant params[ 2 ]; 
    wxString outString = wxT("Some test chars"); 
    params[ 0 ] = row; 
    params[ 1 ] = col; 
    wxAutomationObject objCells = 
    excelObject.GetDispatchProperty(wxT("ActiveSheet.Cells"), 2, params); 
    if (!objCells.PutProperty(wxT("Value"), wxVariant(outString))) { 
        wxLogMessage(wxT("Fail write"));
    

    Leider finde ich keine weiteren Beispiele. Hat jemand schonmal sowas gemacht und kann mir einen Tipp geben ? 😕

    Gruß SciFi

    PS : Es muss nicht unbedingt die aktive Zelle sein, sowas wie Worksheet(1).Cells(5,1).Value = "BLAH" wäre auch Klasse.



  • Ich habs !! 👍 XXX (3 Kreuze mach)

    Das funktioniert :

    wxVariant var; 
         wxAutomationObject excelObject; 
         if (excelObject.CreateInstance("Excel.Application")) 
         { 
    		excelObject.PutProperty(_T("VISIBLE"), true);
    		excelObject.CallMethod("Workbooks.Open", "c:\\test.xls");
    
    		wxAutomationObject range; 
    		wxVariant rng[1]; 
    
    		rng[0] = wxVariant("C3"); 
    
    		excelObject.GetObject(range, "Range", 1,rng); 
    
    		range.CallMethod("Activate"); 
    
    		excelObject.PutProperty("ActiveCell.Value", "Test"); 
    
         } 
         else 
    		 wxMessageBox("ERROR");
    

Anmelden zum Antworten