Xbasic

excel_to_sqlite Function

Syntax

dim result as L = excel_to_sqlite(c excelfilename, c sqlitefilename)

Arguments

excelfilenameCharacter

Filename of the Excel file.

sqlitefilenameCharacter

Filename of the SQLite database to create.

Returns

resultLogical

Returns .t. if the SQLite database was created. Otherwise, returns .f..

Description

Creates a SQLite database file from data in an Excel file.

Discussion

The excel_to_sqlite() function creates a SQLite database file from an Excel file. Each sheet in the Excel file is a table. If the first column in each sheet is numeric data and there are no duplicate values in the column data, that column is configured as the Primary Key for the table in the SQLite database unless the Primary Key is explicitly set by adding '(Primary key)' after the column name in the first row of the Excel sheet. You can also indicate that a column should be indexed by adding '(Index)' after the column name in the Excel shet..

Example

dim filename as c = "C:\temp\customers.xslx"
dim sqliteDbName as c = "customers.db"

if (excel_to_sqlite(filename, sqliteDbName)) then
    ' Success
else 
    ' Could not create SQLite Database
end if