python execl 转html

#!/usr/bin/env python2
# coding=utf-8
import pandas as pd
import codecs
import os
pd.set_option('max_colwidth',2500)
xd = pd.ExcelFile('CommitLog.xls')
df = xd.parse(0,0)
print df.empty
if not df.empty:
  print "merge not null"
  with codecs.open('Log.html','w','utf-8') as html_file:
    html_file.write(df.to_html(header = True,index = False).replace('\\n','<br/>').replace('style="text-align: right;','style="text-align: wrap;'))
else:
  print "merge is null"
  os.popen('touch Log.html')
  with codecs.open('Log.html','w','utf-8') as html_file:
    html_file.write("Submit record is Empty !")

猜你喜欢

转载自my.oschina.net/u/4038454/blog/2966691