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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵