Short version: Using ADO, how can I create an Excel table with the first column containing nrs 0..100
For the last two days I've been playing around with Excel and trying to use it as an ADO table. I found it to be very non-intuitive and buggy but I would really like to get it working.
- Updating data while the user is editing a cell seems to be impossible (any possible work arounds?)
- Deleting records is not possible (any possible work arounds?)
- Inserting starts at an arbitrary point that seems to be maintained by Excel. Even after dropping and re-creating te table.
- If I create a table from SQL the headers are created on row 2 of the Excel sheet (not 1 as I would expect)
I'm using Delphi with ADO to connect to Excel.
Now suppose I want to fill the first column of a table with numbers 0..100. If I connect to Excel I must assume that the table has rubbish in it so I try to lose the records by dropping the table and creating a new one (on the same sheet). I then add new records, but they appear somewhere on row nr 20 (that's how many rows Excel thinks there are). So the first rows only SEEM empty but in reality they are just blank records. Now, how can I create the table starting from row 1?
So far I've played around with these queries:
UPDATE [Sheet1$] SET [R5_L3]=null, [Time]=null, [Offset0]=null, [Offset1]=null
SELECT * FROM [Sheet1$]
INSERT INTO [Sheet1$] ([R5_L3], [Time], [Offset0], [Offset1]) VALUES ('1', '1', '1', '1')
DROP TABLE [Sheet1$]
CREATE TABLE [Sheet1$] ([R5_L3] VARCHAR(40), [Time] VARCHAR(40), [Offset0] VARCHAR(40), [Offset1] VARCHAR(40))
(1) Clears the table --> works fine except that I have idea how to target a specific row after that. (2) Works fine (3) Inserts records starting wherever Excel thinks it should start (and it's wrong most of the time) (4) Clears the Excel sheet (table) including the headers (5) Creates a new table with header on row 2 (instead of row 1). Inserting still starts on arbitrary row