doushi1957
2013-12-12 02:26
浏览 75
已采纳

用于Web应用程序的小型电子表格式语言解释器

I am building a web app which will allow users to create small "spreadsheets" with their data. This is a time keeping application and I am building the reporting tool.

I am looking for a way to for different groups to have different reports without having to hard code in the algorithms. I would like to store these algorithms in a MySQL database and pull it out on a per person basis.

The application allows users to track time and assign it to activities.

The report builder will allow users to select what activities to report on and have the ability to create small equations out the totals.

for instance: One group uses an overtime-given and overtime-paid. The overtime-given needs to be multiplied by 1.5 and then I subtract the overtime-paid from this to give a total.

This is an example output:

|Month|overtime remaining| overtime-paid | overtime-given|
|-----|------------------|---------------|---------------|
| Jan |       7          |      2        |      6        |
| Feb |       9          |      0        |      6        |
| Mar |       0          |      7        |      0        |
| Apr |       7          |      2        |      6        |
| ... |       ...        |     ...       |      ...      |
|THour|       50         |      55       |      70       |//total in hours
|TDay |       7.14       |      7.85     |      10       |//total in days

I am not sure if the best way is to build a small interpreter and create my own tiny language to describe it, or if there is something out there already like this.

I would like to know how other people are creating per user customized reporting tools that the user themselves can alter. Altering I can build I simply UI for users to alter they would not have to code anything.

If someone could point me in the proper direction is greatly appreciated.

Thanks,

图片转代码服务由CSDN问答提供 功能建议

我正在构建一个Web应用程序,允许用户使用他们的数据创建小的“电子表格”。 这是一个计时应用程序,我正在构建报告工具。

我正在寻找一种方法让不同的群体拥有不同的报告,而无需在算法中使用硬编码。 我想将这些算法存储在MySQL数据库中,并按人数将其拉出。

该应用程序允许用户跟踪时间并将其分配给活动。 \ n

报告生成器将允许用户选择要报告的活动,并能够在总计中创建小方程式。

例如:一个组使用加班 - 给予和加班费。 超时给定需要乘以1.5,然后我从中减去加班费以得到总数。

这是一个示例输出:

  | Month |加班剩余| 加班费| 加班赋予| 
 | ----- | ------------------ | --------------- |  -  ------------- | 
 |  Jan |  7 |  2 |  6 | 
 | 二月|  9 |  0 |  6 | 
 |  Mar |  0 |  7 |  0 | 
 | 四月|  7 |  2 |  6 | 
 |  ...... |  ...... |  ...... |  ... | 
 | THour |  50 |  55 |  70 | //总小时数
 | TDay |  7.14 |  7.85 |  10 | //总天数
   
 
 

我不确定最好的方法是建立一个小型解释器并创建我自己的小语言来描述它,或者是否 已经存在这样的事情了。

我想知道其他人如何创建用户自己可以改变的每个用户自定义报告工具。 改变我可以构建我简单的用户界面UI,以便他们不必编写任何代码。

如果有人能指出我正确的方向,我们非常感谢。 \ n

谢谢,

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanshan188866 2014-04-07 11:54
    已采纳

    The general solution to this problem is to use a runtime expression evaluator in the form of scripts. Similar problems appear in handling complex and varying calculations like costing, quoting and payroll.

    To take a simple example, the script code might read:

    $total = $overtime-given * 1.5 - $overtime-paid
    

    The questions are:

    1. What language to use for the expressions.
    2. How to give the language access to the variables it needs (and nothing else)

    The main choices are:

    1. Write your expression evaluator/language. Hard! (but my favorite)
    2. Use the hosting language, if suitable. I believe PHP can be used in this role, but I defer to others as to how well that would work.
    3. Embed a dynamically compiled/interpreted language designed for the purpose. I would suggest Lua, but it depends on whether it can be embedded on your platform.

    This is not a complete answer, but rather a direction to pursue. I have done this in Ruby (embedded my own expression evaluator), but hesitate to suggest it unless you really like compiler technology.

    点赞 打赏 评论

相关推荐 更多相似问题