Home » excel » database – Rails – Spreadsheet adapter

database – Rails – Spreadsheet adapter

Posted by: admin April 23, 2020 Leave a comment

Questions:

Is there a way to use an Excel spreadsheet “as the database” adapter? Instead of writing anything to sqlite3, PostgreSQL, or MySQL, etc. I want to be able to read and write directly to an Excel spreadsheet.

Sqlite3 is just a file system right? Has anyone created an adapter to just use .xls or even .xlsx instead of .sqlite?

I also understand that if it doesn’t exist already, this would probably be difficult to create. I’m not sure how it would work, but that’s not the point of this question.

How to&Answers:

One could use the spreadsheet gem to store/retrieve data from an Excel document, and then mix in the required ActiveModel modules required to make it behave like ActiveRecord. Be sure to use ActiveModel::Lint to ensure that you’ve implemented the ActiveRecord “interface” correctly.