我有以下函数做我想做的事情,除了我不想在新工作表上生成图表,我想将它嵌入到写入数据的工作表中。另外,如何删除图例?这是我所拥有的:
def Get_IV_Data(current_file):
xlApp = win32com.client.Dispatch('Excel.Application')
xlApp.Visible = True
xlBook = xlApp.Workbooks.Add()
xlSheet = xlBook.Sheets(1)
xlSheet.Name = filename
for i in range(0, 10):
fluff = current_file.readline()
Input_Parameters = fluff.split("\t")
from operator import itemgetter
Cal_Std_V = float(itemgetter(2)(Input_Parameters))
xlSheet.Cells(1,1).Value = "V"
xlSheet.Cells(1,2).Value = "I"
xlSheet.Cells(1,3).Value = "P"
output_line = 2
# Assign the data to lists
for line in current_file:
try:
a = line.split("\t")
STD1, STD2, STD3, V, I, Vcorr, Icorr, v1, v2, v3 = a
I = round(float(I) * (Cal_Std_V / float(STD1)), 6)
P = round(float(V) * I, 3)
xlSheet.Cells(output_line, 1).Value = V
xlSheet.Cells(output_line, 2).Value = I
xlSheet.Cells(output_line, 3).Value = P
output_line += 1
except ValueError:
pass
chart = xlApp.Charts.Add()
chart.Name= "Plot "+xlSheet.Name
series = chart.SeriesCollection(1)
series.XValues= xlSheet.Range("A2:A200")
series.Values= xlSheet.Range("B2:B200")
series.Name= filename