Skip to content

The Excel2SQL Processor library provides functionality to map Excel files to SQL scripts that insert rows into a data table. It offers two endpoints for processing Excel files and generating SQL scripts.

License

Notifications You must be signed in to change notification settings

KrzyZyb/Excel2SQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static Badge Build Package Deploy GitHub Release

Excel2SQL

The Excel to SQL Processor library provides functionality to map Excel files to SQL scripts that insert rows into a data table. It offers two endpoints for processing Excel files and generating SQL scripts.

Features

  • Process Excel files (XLS format) and generate SQL scripts for data insertion.
  • Customize output SQL scripts with specified table names and column names.
  • Validate Excel files and configurations to ensure data integrity.

Usage

Dependency

Just use as regular dependency via maven in POM.xml

<dependency> <groupId>io.github.krzyzyb</groupId> <artifactId>xls2sql</artifactId> <version>1.1.3</version> </dependency>

Don't forget to inform maven that you are using dependencies from github package registry. Update POM.xml with:

<repositories> <repository> <id>github</id> <url>https://maven.pkg.github.com/krzyzyb/xls2sql</url> </repository> </repositories>

Default Processing Method

Xls2SqlProcessor.process(Path inputFile, Path outputFile)

In the default processing method, Xls2SqlProcessor.process, provide the path to the input Excel file (inputFile) containing the data to insert and the path to the output SQL script file (outputFile). The library automatically generates an SQL script with column names extracted from the XLS header and the table name derived from the output file name.

Custom Processing Method

Xls2SqlProcessor.process(Path inputFile, Path outputFile, OutputFileConfig config)

In the custom processing method, Xls2SqlProcessor.process, provide the path to the input Excel file (inputFile), the path to the output SQL script file (outputFile), and a custom configuration (config). The configuration (OutputFileConfig) allows you to customize the table name and column names for the output SQL script.

Example

Path inputFile = Paths.get("./user/Source.xls");
Path outputFile = Paths.get("./user/Destiny.sql");

// Default processing method
Xls2SqlProcessor.process(inputFile, outputFile);

// Custom processing method with configuration
OutputFileConfig config = new OutputFileConfig("CustomTableName", Arrays.asList("Column1", "Column2"));
Xls2SqlProcessor.process(inputFile, outputFile, config);

Requirements

  • Java 8 or higher

License

This library is licensed under the MIT License.

About

The Excel2SQL Processor library provides functionality to map Excel files to SQL scripts that insert rows into a data table. It offers two endpoints for processing Excel files and generating SQL scripts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages