예제 #1
0
def pop_excl (sv_dict, ClusName):
	wb = openpyxl.Workbook ()
	sh = wb.active		
	count1 = 0
	count2 = 2
	alph = ['a', 'b', 'c', 'd']
	f = sh['a1'] 
	f.font = Font (bold=True)
	f = sh['b1'] 
	f.font = Font (bold=True)
	sh.title = 'HighLevel'
	sh['a1'] = 'StorageView'
	sh['b1'] = 'Size(G)'
	for i in sv_dict:
		sh[alph[count1] + str (count2)] = i
		count1 += 1
		sh[alph[count1] + str (count2)] = float (sv_dict[i][-1][-1])
		count2 += 1
		count1 = 0
	count2 = 2
	for i in sv_dict:
		sh = wb.create_sheet (i)		
		sh = wb.get_sheet_by_name (i)
		f = sh['a1']
		f.font = Font (bold=True)
		f = sh['b1']
		f.font = Font (bold=True)
		f = sh['c1']
		f.font = Font (bold=True)
		f = sh['d1']
		f.font = Font (bold=True)
		sh['a1'] = 'LunID'
		sh['b1'] = 'Name'
		sh['c1'] = 'VPD'
		sh['d1'] = 'Size(G/T)'
		for j in range (len (sv_dict[i])):
			for k in range (4):
				sh[alph[count1] + str (count2)] = sv_dict[i][j][k]
				count1 += 1
			count2 += 1
			count1 = 0
		count2 = 2

	logging.debug('Start of chart')
	l = len(sv_dict)

	sh = wb.get_sheet_by_name ('HighLevel')
	logging.debug('sheets: %s' % (wb.get_sheet_names ()))
	logging.debug('sh: %s' % (sh.title))
	chart1 = BarChart()
	chart1.type = "col"
	chart1.style = 11
	chart1.title = "VPlex Capacity Report"
	chart1.y_axis.title = 'Size'
	chart1.x_axis.title = 'View Name'
	logging.debug('len of sv_dict: %d' % (l))
	data = Reference(sh, min_col=2, min_row=2, max_row=l + 1, max_col=2)
	cats = Reference(sh, min_col=1, min_row=2, max_row=l + 1)
	chart1.add_data(data, titles_from_data=False)
	chart1.set_categories(cats)
	chart1.top = 100
	chart1.left = 30
	chart1.width = 27
	chart1.height = 10
	chart1.shape = sh.add_chart(chart1, "D2")

	wb.save (ClusName)
	return 0