La idea es que Python lea las celdas del archivo excel y vaya escribiendo el archivo HTML un dato a la vez:
import xlrd
def upload():
mobile = open('d:/rubenBk/HTML/mobile quota.html', 'w')
report = xlrd.open_workbook('D:/RubenBK/Reports/cctableruben.xlsm')
sheet = report.sheet_by_name('Licencias')
mobile.write('<body style="background-color:yellow">')
mobile.write('<table>')
for r in range(sheet.nrows):
mobile.write('<tr>') #creates the row
for c in range(sheet.ncols):
if unicode(sheet.cell_value(r,c)).encode('utf-8') != '': #if the cell contais data, apply a border to it.
mobile.write('<td style = "border-style:solid; border-width:1px">' + unicode(sheet.cell_value(r,c)).encode('utf-8') + '</td>')#fills data in row
else:
mobile.write('<td>' + unicode(sheet.cell_value(r,c)).encode('utf-8') + '</td>')#fills data in row
mobile.write('</table>')
mobile.write('<a href = "D:/RubenBK/HTML/Home.html">Home</a>')
mobile.write('</body>')
if __name__ == '__main__':
upload()
No hay comentarios:
Publicar un comentario