Hello Everyone!
I’d like to share a proof of concept I recently worked on, demonstrating how to synchronize Excel data with Data Blaze using VBA. The goal was to validate whether Excel could be seamlessly integrated with Data Blaze, enabling real-time synchronization of data with minimal manual effort.
Use Case: Excel Synchronization with Data Blaze
This proof of concept explores how to:
Export Data to CSV: Extract data from an Excel sheet and save it as a UTF-8 formatted CSV file for import into Data Blaze.
Import into Data Blaze: Populate a Data Blaze table with the exported CSV data.
Initialize ID Mapping: Create a hidden DataBlaze_Tracking sheet to map id_blaze (generated by Data Blaze for each row) to id_excel (unique IDs from the original Excel file). This step ensures we can track and update specific rows in Data Blaze later.
Track Changes in Excel: Monitor changes in the selected sheet and log them in a separate "Changements" sheet.
Synchronize Changes Back to Data Blaze: Push updates from the "Changements" sheet back to Data Blaze using its API.
How It Works
Export to CSV: Data from the selected sheet is exported to a CSV file using a VBA script. This ensures compatibility with Data Blaze.
Import to Data Blaze: The CSV file is uploaded to Data Blaze to populate the table with initial data.
Initialize ID Mapping:
When the CSV file is uploaded, Data Blaze generates unique id_blaze values for each row.
A VBA script retrieves these IDs using the Data Blaze API and maps them to the corresponding id_excel in a hidden DataBlaze_Tracking sheet.
This mapping is critical for identifying rows in Data Blaze when pushing updates.
Track Changes in Excel:
A VBA script monitors changes (edits or new rows) in the selected sheet and logs these changes in a "Changements" sheet.
Sync Updates Back to Data Blaze:
Logged changes in the "Changements" sheet are sent to Data Blaze using PATCH API requests, keeping the Data Blaze table synchronized with Excel.
Challenges Encountered
One of the biggest challenges was updating rows in Data Blaze. When a CSV is imported into Data Blaze, each row is assigned a unique id_blaze. However, I initially intended to use a unique identifier (id_excel) from my CSV to locate and update rows via the API. Unfortunately, this approach didn’t work as expected.
To overcome this, I had to:
Map the id_blaze values generated by Data Blaze to their corresponding id_excel values in a separate hidden sheet (DataBlaze_Tracking).
Use the id_blaze values for updates, as the API required them for precise row identification.
This extra step added complexity to the synchronization process, but it ultimately enabled successful updates.
Despite the challenges, this proof of concept successfully demonstrated that synchronization between Excel and Data Blaze is achievable.
If you’ve worked on similar integrations or have any suggestions for improvement, I’d love to hear your thoughts!