在断开连接的环境中更新 excel 或 xml 数据源的最佳实践?

发布于 2024-08-16 18:59:37 字数 234 浏览 2 评论 0原文

我有一个将离线运行的应用程序,因此没有数据库连接。 我的数据源选项是 Excel Spreedsheet、CSV 或 XML 文件。

应用程序需要能够搜索记录并更新它。 最好的方法是什么?

  1. 我应该将整个电子表格加载到内存中,然后在内存(缓存)中使用它吗?听起来很高效,但是有风险。

  2. 我是否应该每次都扫描然后每次更新,听起来 xml 文件最适合这个

I have a application that will be run offline so there is no database connection.
My options for the data-source are Excel Spreedsheet, CSV, or XML files.

The application needs to be able to search for a record and update it.
What's the best way to do this?

  1. Should I load the entire spreadsheet into memory and then work with it in memory (cache)? It sounds efficient, but risky.

  2. Should I do a scan each time and then update each time, it sounds like an xml file would work best for this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七婞 2024-08-23 18:59:37

Xml 非常适合此类任务...您可以轻松解析并修改它。
如果您需要更多逻辑,可以使用 Apache Digester。但它更适合小型 xml 文件。
您可以根据 XML 结构创建 Java 对象。

希望这有帮助。

编辑:
我想补充的一件事是……文档的“新”.docx 类型已经是一个 XML 文件夹。
因此,工作/修改 Excel 表格变得更加容易。他们也将它用于 Exel Sheets..不确定类型名称..类似于“.xlsx”?

Xml is really nice for such tasks...you can parse it easily and modify it.
If you need more logic you can use Apache Digester. But it is more made for small xml Files.
You can create Java Objects out of the XML structure.

Hope this helps.

Edit:
One thing i like to add...that the "new" .docx Type for Documents is already an XML Folder.
So working/modifying Excel Sheets got easier. They use it for Exel Sheets too..not sure about the type name..something like ".xlsx"?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文