Import Excel in Database New Created Table

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
KernConcept
Posts: 1
Joined: Wed Aug 10, 2016 8:53 am

Import Excel in Database New Created Table

Post by KernConcept »

Hi,

I need to import an Excel sheet into a database table.
The table doesn't exist, so it must be created by reading the Excel exactly by the first row.

For each column the database type must be set.
So how can i set "DATE", "TIME" or "INTEGER" datatype in the create SQL Statement?
The TXLSCellType has none of this types. Only string and float.

Thanks
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Import Excel in Database New Created Table

Post by larsa »

Hello

An Excel worksheet has four types of cells, string, float, boolean and error. Integers are written as float. Date and time are also written as float but the cell is formatted to show the value as a date or time value. Example:

Code: Select all

  // Add two cells with the current date and time.
  XLS[0].AsFloat[1,1] := Now;
  XLS[0].AsFloat[1,2] := Now;

  // Format cell B2 as date.
  XLS[0].Cell[1,1].NumberFormat := 'YYYY-MM-DD';
  // Format cell B3 as time.
  XLS[0].Cell[1,2].NumberFormat := 'HH:MM';
Lars Arvidsson, Axolot Data
Post Reply