![]() |
Excel 'dynamisch' machen
Moin,
der Titel ist vllt. etwas unpassend, aber ich habe folgendes Problem: Ich lese aus einer BDE Werte aus. Diese sollen nun in Excel rein, das Problem ist, das sich die BDE verändert, also manchmal habe ich dann eine Spalte mit 36 Zeilen und manchmal eben eine Spalte mit 55 Zeilen. Jetzt wüsste ich gerne ob es einen Befehl gibt, der sich die nächste, leere Spalte sucht und dort reintippt. Sonsg müsste ich ja immer wieder den Code neu Tippen. Ich stele mir das so vor:
Delphi-Quellcode:
//So würde ich es normalerweiße machen:
Excel.Cells[2, 4].Value := 'Testwert1'; Excel.Cells[2, 4].Value := 'Testwert2'; Excel.Cells[2, 4].Value := 'Testwert3'; Excel.Cells[2, 4].Value := 'Testwert4'; Excel.Cells[2, 4].Value := 'Testwert5'; [...] //Aber ich suche sowas wie: Excel.Cells[2, NextFreeRow].Value := 'Testwert'; //Hoffe es ist verständlich :P |
AW: Excel 'dynamisch' machen
vielleicht in einer schleife, die die anzahl der zeilen durchgeht?
Delphi-Quellcode:
nur als kleiner denkanstoß ;)
for i := 0 to RowCount do
begin Excel.Cells[2, i].Value := 'Testwert' + IntToStr(i); end; |
AW: Excel 'dynamisch' machen
Hier die VBA Version, Delphiumsetzung überlass ich dir selber.
Code:
nb:
Sub test()
Dim w As Worksheet, r As Range, i As Long Set w = ActiveWorkbook.Worksheets(1) Set r = w.Columns(2) i = r.SpecialCells(xlCellTypeLastCell).Row w.Cells(i, 2).Value = 4 End Sub const xlCellTypeLastCell = 11 hth Jumpy |
AW: Excel 'dynamisch' machen
Sorry, war 'ne dumme Frage von mir, habs gelöst mit:
Delphi-Quellcode:
while (not Table1.Eof) do
begin Excel.Cells[i, 1].Value := Table1D.Value; Excel.Cells[i, 2].Value := Table1Z.Value; Excel.Cells[i, 4].Value := Table1B.Value; Excel.Cells[i, 5].Value := Table1W.Value; Excel.Cells[i, 6].Value := Table1Be.Value; Excel.Cells[i, 7].Value := Table1M.Value; Excel.Cells[i, 8].Value := Table1P.Value; Excel.Cells[i, 9].Value := Table1E.Value; Excel.Cells[i, 10].Value := Table1A.Value; Excel.Cells[i, 11].Value := Table1Ec.Value; Table1.Next; i := i + 1; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:06 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz