dqwh1218 2013-04-23 20:27
浏览 50
已采纳

在PHP中处理服务器上的Excel公式

I have a rather complex spreadsheet formula. Right now I am using PHPExcel to load the spreadsheet into memory, and I set the cell values of the formula input to the values from a front-end form (using ajax), get the calculated result and send it back to the client.

Is this the best way to this? Or should the formulas be converted to pure php?

If this is an okay method, I have concerns regarding concurrency and memory usage.

The spreadsheet isn't that large, less than 1000 cells. How can I calculate the threshold for concurrency (people clicking calculate on the front end) and memory usage on the server?

What steps can I take to optimise this algorithm (caching for example) whilst balancing performance?

  • 写回答

1条回答 默认 最新

  • douren2395 2013-04-23 20:40
    关注

    You're going to have problems doing this as an ajax request for large numbers of concurrent users, because these http requests have no persistence, so you need to load the spreadsheet file for every request. What it does guarantee is that each request runs independently with its own copy of the spreadsheet, so no individual user's request will affect any of the other users requests.

    The other extreme is to take all the Excel logic and rewrite it in PHP. You don't give any indication of the complexity of your spreadsheet formulae, so it's difficult to judge how complex a task this would be.

    A third option would be to use only PHPExcel's calculation engine, feeding it with the form values and formulae directly. This eliminates the time and memory overheads of loading the spreadsheet file with every request, so could be the easiest and most efficient option. You can find an example of this in the Quadratic2.php example file in the /Tests directory of the PHP distribution.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助