# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals

import frappe
from frappe.utils import encode, cstr, cint, flt, comma_or

import openpyxl
from cStringIO import StringIO
from openpyxl.styles import Font

# return xlsx file object
def make_xlsx(data, sheet_name):

	wb = openpyxl.Workbook(write_only=True)
	ws = wb.create_sheet(sheet_name, 0)

	row1 = ws.row_dimensions[1]
	row1.font = Font(name='Calibri',bold=True)

	for row in data:
		ws.append(row)

	xlsx_file = StringIO()
	wb.save(xlsx_file)
	return xlsx_file
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals

import frappe
from frappe.utils import encode, cstr, cint, flt, comma_or

import openpyxl
from cStringIO import StringIO
from openpyxl.styles import Font

import html2text

# return xlsx file object
def make_xlsx(data, sheet_name):

	wb = openpyxl.Workbook(write_only=True)
	ws = wb.create_sheet(sheet_name, 0)

	row1 = ws.row_dimensions[1]
	row1.font = Font(name='Calibri',bold=True)

	for row in data:
		clean_row = []
		for item in row:
			obj = html2text.HTML2Text()
			obj.ignore_links = True
			obj.body_width = 0
			obj = obj.handle(item)
			obj = obj.rsplit('\n', 1)
			clean_row.append(obj[0])
		ws.append(clean_row)


	xlsx_file = StringIO()
	wb.save(xlsx_file)
	return xlsx_file
remove html tags when exporting report in excel format (#3174)