python pandas implements a method for converting excel to html format

  • 2020-12-22 17:44:13
  • OfStack

As shown below:


#!/usr/bin/env Python
# coding=utf-8
import pandas as pd
import codecs
xd = pd.ExcelFile('/Users/wangxingfan/Desktop/1.xlsx')
df = xd.parse()
with codecs.open('/Users/wangxingfan/Desktop/1.html','w','utf-8') as html_file:
 html_file.write(df.to_html(header = True,index = False))

Related articles: