1 Star 0 Fork 0

seawaycao/SQLiteForExcel_refactored

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Overview

This project is a forked version of Govert's SQLite for Excel. The main difference is that the code has been refactored to uses classes as opposed to the standard modules that the original project utilized. The original code was stored in two modules: Sqlite3 and Sqlite3Demo. I've since updated these files to the class modules cSqlite3 and cSqlite3Demo respectively. I've also added an ISqlite3 interface which cSqlite3 implements. My code also removed unnecessary conditional compilation from the codebase.

Motivations for refactoring

  1. There were a few bugs in Sqlite3 and Sqlite3Demo modules. In cSqlite3, code needed to be run to set the correct path for the directory the workbook and database were located in (it defaulted to the user's My Documents folder). For cSqlite3Demo, the TestFile file that all of the tests utilized was only created if you ran the AllTests method. If you tried to run other tests directly, you'd get an error. Both of these issues were easily fixed by using each class's constructor. So these bugs are no longer an issue.
  2. Using class modules allows you to use interfaces and polymorphism which make for easy refactoring, unit testing, etc.
  3. I deleted some unnecessary code related to conditional compilation. This was used in many procedures to alternate between two different data types: long and longPtr. These data types were used on 32-bit and 64-bit systems respectively. However, this code was not needed. As you can see in this MDSN link, longPtr transforms to long in 32 bit, and longLong in 64 bit environments. So the conditional compilation between one type to the other is not necessary.

Known bugs

  1. One of the test methods in cSqlite3Demo, TestBackup, throws an error. It is the only method among those called in the AllTests method that throws an error. I tested the method in the original code, and it also threw an error. So the error is not a result of refactoring. Since the method was throwing an error, the calling code in the AllTests method has been commented out. However, the original code for the method is still there.
  2. One of the original test methods in cSqlite3Demo, TestBinding, threw an error after refactoring. This error happens in the for loop in the code. The original code tested 100,000 elements. After refactoring, only 97,262 elements work. I have no idea why this is the case. But the code has been updated to this new upper bound so the test works. The original code with the original upper bound is left in the code but commented out.
  3. I am not able to get this code the file to work on my cloud-storage directory. If you're having similar issues, it may help to move the file to a network drive or some other directory where this isn't an issue.

Potential bugs

This code may not be compatible with 32-bit versions of Office. Govert also noted that removing code related to conditional compilation may affect versions of Excel prior to 2010 (i.e. 2007 or earlier)

If either of those are issues for you, I would recommend using the code in Govert's original project.

Future updates

Some updates I'm considering in the future include moving certain methods around and making certain methods private to assist in abstraction for the respective objects. Other potential updates may include writing code to make working with the default database easier. And perhaps creating an ORM that would make working with the database easier. The internal design of the original API is a bit complicated. So it will take some time for me to familiarize myself with it.

Example

This is sample code taken from the mMain module which is included in the Excel workbook:

Sub Main()
    Dim sqlite As ISqlite3
    Dim demo As cSqlite3Demo
    
    Set sqlite = New cSqlite3
    Set demo = New cSqlite3Demo
    
    demo.init sqlite
    demo.AllTests
End Sub
The MIT License (MIT) Copyright (c) Govert van Drimmelen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cauve/sqlite-for-excel_refactored.git
git@gitee.com:cauve/sqlite-for-excel_refactored.git
cauve
sqlite-for-excel_refactored
SQLiteForExcel_refactored
master

搜索帮助