
Convert Excel Workbook to SQL File with Node.js SDK.
Migrating data from spreadsheets to databases is a common task in data-driven applications. Converting an Excel workbook to SQL script allows developers to automate data imports and integrate spreadsheet information directly into relational databases.
In this article, you’ll learn how to convert Excel to SQL using Node.js and the Aspose.Cells Cloud SDK, making the entire process secure, efficient, and developer-friendly.
- 🚀 Excel to SQL REST API for Node.js
- 📄 Convert Excel to SQL using Node.js
- 💻 Excel to SQL Script Conversion using cURL
🚀 Excel to SQL REST API for Node.js
Aspose.Cells Cloud SDK for Node.js supports a wide variety of formats including XLS, XLSX, XLSM, and allows for exporting to SQL effortlessly.
✅ Why use Aspose.Cells Cloud SDK?
- Exports tables and data from Excel to valid SQL.
- Supports cloud-based workflows.
- Reduces manual data entry and transformation errors.
📦 Install the SDK
npm install asposecellscloud --save
In order to use the API, we need to generate Client ID and Client Secret from the Aspose.Cloud dashboard. For further details, please visit quick start article.
📄 Convert Excel to SQL using Node.js
Use the following code snippet to convert an Excel file into an SQL script:
- Firstly, create an object of CellsApi class by providing Client ID and Client Secret as arguments.
- Read input XLS file using createReadStream(…) method and then uploadFile(…) method to upload the file to cloud storage.
- Create an object of PostWorkbookSaveAsRequest class and then call postWorkbookSaveAs(..) method to initiate the XLS to SQL conversion process.
A preview of Excel to SQL file conversion.
- For testing purposes, we have also attached the input Excel workbook sourceExcel.xlsx.
💻 Excel to SQL Script Conversion using cURL
If you prefer command-line tools, here’s how to convert Excel to SQL using cURL and the Aspose.Cells Cloud API:
✅ Benefits of using cURL:
- No local installations required.
- Ideal for automation and CI/CD workflows.
Step 1: Generate Access Token
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=XXXXXX-XXXXXX-426c-85f7-7d458b112383&client_secret=CLIENT_SECRET" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Step 2: Execute Excel to SQL Conversion
The following request method requires the input Excel workbook to be already available in the cloud storage.
curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}?format=SQL&isAutoFit=true&onlySaveTable=true&outPath={output}&checkExcelRestriction=true" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-d {}
Replace sourceFile
with the name of source Excel workbook, output
with the name of resultant SQL script file and accessToken
with a JWT access token generated above.
🧪 Try Free Excel to SQL Online Tool
Want a quick test? Use our Excel to SQL Converter App to try it online without writing any code.
A preview of Excel to SQL file converter.
✅ Conclusion
Using Aspose.Cells Cloud SDK for Node.js, you can effortlessly convert Excel to SQL script files, streamline your data migration process, and minimize the risk of manual errors.
Whether you’re developing a backend solution or running automated tasks, the API’s flexibility and cross-platform support make it ideal for modern web and enterprise applications.
🔗 Useful Resources
📚 Recommended Articles
We highly recommend visiting the following blogs: