Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在django网页中显示excel另存为的html文件?_Python_Html_Python 3.x_Django_Excel - Fatal编程技术网

Python 如何在django网页中显示excel另存为的html文件?

Python 如何在django网页中显示excel另存为的html文件?,python,html,python-3.x,django,excel,Python,Html,Python 3.x,Django,Excel,我想在django网页中显示excel文件,下面是我尝试的内容: 1.将excel上传到Google Drive/Microsoft上,然后使用trains链接 坏:我的公司防火墙禁止谷歌硬盘/微软 2.使用pandaspd.读取excelread excel并使用to\u html()创建html页面 错误:仅原始数据,未使用excel格式 3.使用python打开excel并将其另存为html: from win32com.client import Dispatch EXCEL_FILE

我想在django网页中显示excel文件,下面是我尝试的内容:

1.将excel上传到Google Drive/Microsoft上,然后使用trains链接

坏:我的公司防火墙禁止谷歌硬盘/微软

2.使用pandas
pd.读取excel
read excel并使用
to\u html()
创建html页面

错误:仅原始数据,未使用excel格式

3.使用python打开excel并将其另存为html:

from win32com.client import Dispatch
EXCEL_FILE = "tmp123.xls"
EXCEL_SAVEAS_HTML_FILE = "tmp123.html"
xl = Dispatch('Excel.Application')
rb = xl.Workbooks.Open(EXCEL_FILE )
rb.SaveAs(EXCEL_SAVEAS_HTML_FILE , FileFormat=44)
xl.Quit()
此方法生成html文件后,但此html文件不是单个html。 它包含一个“.files”文件夹,内部有自己的link&js函数,如下所示:

文件夹结构:

-tmp123.html
-tmp123.files
 |
 |-filelist.xml
 |-sheet001.html
 |-sheet002.html
 |-stylesheet.css
 |-tabstrip.html
<link rel=File-List href="tmp123.files/filelist.xml">
<link id="shLink" href="tmp123.files/sheet001.html">
<link id="shLink" href="tmp123.files/sheet002.html">
window.location.replace("../tmp123.html");
链接:

-tmp123.html
-tmp123.files
 |
 |-filelist.xml
 |-sheet001.html
 |-sheet002.html
 |-stylesheet.css
 |-tabstrip.html
<link rel=File-List href="tmp123.files/filelist.xml">
<link id="shLink" href="tmp123.files/sheet001.html">
<link id="shLink" href="tmp123.files/sheet002.html">
window.location.replace("../tmp123.html");
这个“tmp123.html”可以在本地运行良好, 但是当我访问
/test/
url并直接返回django中的这个html页面时
返回render(请求“tmp123.html”,locals())
,它做得不好, 因为此链接&js函数在所有本地路径中都有:

[17/Sep/2020 13:54:20] "GET /test/ HTTP/1.1" 200 12961
[17/Sep/2020 13:54:22] "GET /test/tmp123.files/sheet001.html HTTP/1.1" 200 7037
[17/Sep/2020 13:54:23] "GET /test/tmp123.files/tabstrip.html HTTP/1.1" 200 7037
我的问题是如何使用这种从django网页上的excel显示保存的html页面? 非常感谢