简体   繁体   中英

Is it possible to import an excel sheet as a table in the database?

This is the first time that I am attempting this, and I don't know if it is possible. I am trying to develop an application that allows me to upload an excel file directly into a database.

Is it possible to upload the excel data without first converting the excel sheet to the CSV format? The database table contains fields and columns with the same names as the excel file.

Does anyone know of a tool which can do this for me?

it is certainly possible. You might be interested in the JBoss Teiid project , which enables accessing Excel spreadsheet like it was a table.

Given that, you can then easily fill all the values from a "virtual" table formed from the spreadsheet (let's call it excelTable) into another table (let's call it targetTable):

INSERT INTO targetTable(column1,...) SELECT column1,... FROM excelTable;

The project is open-source so if its usage doesn't fit your needs, you can always look at the sources and maybe get an inspiration, how you can do such things.

Best regards

Jan

For Oracle, the easiest way is to use sqlldr for bulk load.

So you need an application that will parse the xls/xlsx and write a data file for sqlldr (can be csv , in fact any delimited text file).

If you really don't want to convert the file you could parse it and insert each row at a time, but this method is very slow when dealing with a lot of data.

Sqlldr FAQ

EDIT : Equivalent tool for sqlserver is called BCP

BCP Tool

And of course, you can use the tools withouth any software attached, running them via command lines once you have the data and/or control files ready.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM