EasyXLS

How to import Excel data to MySQL, SQL Server in PHP or Classic ASP

EasyXLS™ library allows you to import Excel data to SQL tables. The data can be imported from an Excel sheet or from the active Excel sheet. The entire sheet data or only data from ranges of cells can be imported.

EasyXLS can be successfully used to also import large Excel files having big volume of data with fast importing time.

EasyXLS permits you to import Excel files without Excel installed, without OLEDB, without Interop or any other additional software installed.

Source code sample

Step 1: Download and install EasyXLS Excel Library for .NET/COM+

To download the trial version of EasyXLS Excel Library, press the below button:

Download EasyXLS™ Excel Library for COM+

If you already own a license key, you may login and download EasyXLS from your account.

Step 2: Verify if EasyXLS is registered

Check if EasyXLS component is present in Component Services.

Step 3: Run PHP/ASP code that imports Excel file to SQL database

The below example shows how to import Excel file to SQL database in PHP and Classic ASP. The Excel will be imported to a list of Excel rows and later, the records can be inserted into the database using SQL syntax.

PHP
ASP

Import Excel to MySQL, SQL Server or any other database

Once the Excel data is imported to List, the records can be processed and entered into database using INSERT, UPDATE or other SQL commands specific to SQL Server, MySQL, Oracle, MS Access or any other database.

Import Excel file having one sheet to MySQL table

Importing the Excel file data to SQL database, if the Excel file has only one sheet, is the easiest approach. The Excel data can be imported with one single line of code using:
- ExcelDocument.easy_ReadXLSXActiveSheet_AsList method for XLSX file
- ExcelDocument.easy_ReadXLSBActiveSheet_AsList method for XLSB file
- ExcelDocument.easy_ReadXLSActiveSheet_AsList method for XLS file

The above code sample shows how to achieve this goal.

Import Excel file having multiple sheets to MySQL table

There are three approaches for importing data from an Excel file with multiple sheets.

I. Usually the first sheet is the active sheet inside an Excel file. If this is your case or if you are importing data from another active sheet use:
- ExcelDocument.easy_ReadXLSXActiveSheet_AsList method for XLSX file
- ExcelDocument.easy_ReadXLSBActiveSheet_AsList method for XLSB file
- ExcelDocument.easy_ReadXLSActiveSheet_AsList method for XLS file

II. For importing data from an Excel sheet and the name of the sheet is known, EasyXLS recommends the use of:
- ExcelDocument.easy_ReadXLSXSheet_AsList method for XLSX file
- ExcelDocument.easy_ReadXLSBSheet_AsList method for XLSB file
- ExcelDocument.easy_ReadXLSSheet_AsList method for XLS file

III. For importing data from an Excel sheet and the name of the sheet is not known, the first step is to find the sheet name using:
- ExcelDocument.easy_ReadXLSXFile_SheetNames method for XLSX file
- ExcelDocument.easy_ReadXLSBFile_SheetNames method for XLSB file
- ExcelDocument.easy_ReadXLSFile_SheetNames method for XLS file

Then, import the sheet data in DataSet using:
- ExcelDocument.easy_ReadXLSXSheet_AsList method for XLSX file
- ExcelDocument.easy_ReadXLSBSheet_AsList method for XLSB file
- ExcelDocument.easy_ReadXLSSheet_AsList method for XLS file

Import range of Excel cells to MySQL table

EasyXLS enables you to import Excel data to SQL database either from the entire sheet or from a range of cells. Importing only a range of cells is a very useful option especially for large Excel files because it reduces the speed of the import process.

In order to import multiple cell ranges at once from Excel sheet, the range parameter must be passed to the method as union of ranges (multiple ranges separated by comma).

All the methods that allow importing Excel to List have parameters that permit importing only ranges of cells.

Import XLSX, XLSM, XLSB and XLS files to MySQL table

This code sample shows how to import XLSX file to SQL database. Similarly, you can import XLSM, XLSB, XLS files to database using:
- ExcelDocument.easy_ReadXLSXActiveSheet_AsList or ExcelDocument.easy_ReadXLSXSheet_AsList method for XLSX and XLSM files
- ExcelDocument.easy_ReadXLSBActiveSheet_AsList or ExcelDocument.easy_ReadXLSBSheet_AsList method for XLSB files
- ExcelDocument.easy_ReadXLSActiveSheet_AsList or ExcelDocument.easy_ReadXLSSheet_AsList method for XLS files

Getting started with EasyXLS Excel library

To download the trial version of EasyXLS Excel Library, press the below button:

Download EasyXLS™ Excel Library for PHP and Classic ASP

If you already own a license key, you may login and download EasyXLS from your account.



Available for: Professional, Excel Reader
Go to top

EasyXLS Excel libraries:

.NET
COM+ Excel Library
full COM+ version to import, export or convert Excel files
COM+ Excel Reader
COM+ version to read and import Excel files
Download EasyXLS™ Excel Component for PHP and Classic ASP

File formats:

Office 365
MS Excel 2021 - 2024
MS Excel 2007 - 2019
MS Excel 97 - 2003
XLSXXLSMXLSBXLS
XMLHTMLCSVTXT