45 lines
1.5 KiB
PHP
Raw Normal View History

2024-08-31 01:03:37 +08:00
<?php
/**
* office文档前端解析
*
* dochttps://github.com/SheetJS/js-word // x
* docxhttps://github.com/mwilliamson/mammoth.js
* xls/xlsxhttps://github.com/SheetJS/sheetjs
* xlsxhttps://github.com/mengshukeji/Luckysheet
* https://mengshukeji.github.io/LuckysheetDocs/zh/guide
* https://madewith.cn/709
* ppthttps://github.com/SheetJS/js-ppt // x
* pptxhttps://github.com/meshesha/PPTXjs
*
*/
class officeViewerJsOfficeIndex extends Controller {
protected $pluginName;
public function __construct() {
parent::__construct();
$this->pluginName = 'officeViewerPlugin';
$this->appName = LNG('officeViewer.jsOffice.name');
}
public function index(){
$plugin = Action($this->pluginName);
if(!$plugin->allowExt('js')) {
$plugin->showTips(LNG('officeViewer.main.invalidExt'), $this->appName);
}
$extList = array(
'docx' => 'mammothjs',
'doc' => 'mammothjs',
'xlsx' => 'luckysheet', // sheetjs
'xls' => 'luckysheet',
'csv' => 'luckysheet',
'pptx' => 'pptxjs',
'ppt' => 'pptxjs',
);
// doc、ppt不支持此处为兼容某些旧格式命名的新结构zip文件
$ext = $this->in['ext'];
if(!isset($extList[$ext])) {
$plugin->showTips(LNG('officeViewer.main.invalidExt'), $this->appName);
}
$app = $extList[$ext];
$plugin->showJsOffice($app);
}
}