excel 显示 html代码,excel转成html显示

66b52468c121889b900d4956032f1009.png

8种机械键盘轴体对比

本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?

最近遇到一个需求,后台将excel文件上传,前台直接显示在页面上显示。

查阅一些资料之后,最终选定的方案是将excel文件直接转成html文件,然后链接显示。

excel转成html文件工具:

​ libreoffice1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25Name

libreoffice - LibreOffice office suite

SYNOPSIS

libreoffice [--accept=accept-string] [--base] [--calc] [--convert-to output_file_extension[:output_filter_name] [--outdir output_dir] file]... [--display display]

[--draw] [--global] [--headless] [--help|-h|-?] [--impress] [--invisible] [--infilter=""] [--math] [--minimized] [-n file]... [--nodefault] [--nolockcheck]

[--nologo] [--norestore] [-o file]... [-p file...] [--print-to-file [--printer-name printer_name] [--outdir output_dir] file]... [--pt printername file...] [--show

Impress file]... [--unaccept=accept-string] [--terminate_after_init] [--view file]... [--web] [--writer] [file...]

lobase

localc

lodraw

lofromtemplate

loimpress

lomath

loweb

lowriter

DESCRIPTION

LibreOffice (LO for short) is a multi-platform office productivity suite. It was derived from OpenOffice.org 3.3 Beta on September 28, 2010.

libreoffice is a shell script that sets up the environment and passes the command line arguments to the soffice.bin binary.

Alternatively, the following helper scripts start the respective module:

sbase, scalc, sdraw, simpress, smath, sofficerc, swriter

这个工具很强大,doc,pdf等格式文件都可以转换。

用法示例1libreoffice --convert-to html inpout_file --outdir output_path

有了工具之后,功能实现如下:将文件上传,然后调用libreoffice将文件转成html格式。1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27if (request()->isPost()) {

$file = request()->file('file');

if (!$file) {

$this->error('请上传附件');

}

$info = $file->move(Env::get('root_path').'/uploads');

if ($info) {

//$data = array();

$data = input('post.');

exec("libreoffice --convert-to html ".Env::get('root_path').'/uploads/'.$info->getSaveName()." --outdir ".Env::get('root_path').'/uploads/'.pathinfo($info->getSaveName()

, PATHINFO_DIRNAME));

$str = explode('.', $info->getSaveName());

$data['fee_file'] = $str[0].'.html';

$add = thinkDb::name('fees')->insert($data);

if ($add) {

$this->redirect('lst');

} else {

$this->error('添加失败');

}

} else {

// 上传失败获取错误信息

$this->error($file->getError());

}

}

遇到问题,PHP调用系统命令时出错。1settings Disable exec, shell_exec, system, popen and Other Functions To Improve Security

为了安全,php默认将这几个函数都给屏蔽了。

解决方法:在php.ini中修改配置。

查找php.ini方法:1

2

3

4

5Configuration File (php.ini) Path: /www/server/php/56/etc

Loaded Configuration File: /www/server/php/56/etc/php.ini

Scan for additional .ini files in: (none)

Additional .ini files parsed: (none)

在文件中查找这行代码:1

2

3

4; This directive allows you to disable certain functions for security reasons.

; It receives a comma-delimited list of function names.

; http://php.net/disable-functions

disable_functions = passthru,system,chroot,chgrp,chown,shell_exec,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru

将你要使用的函数从中删除,保存文件。然后重启php-fpm即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值