python读取excel绘图_如何使用Python在excel2003的工作表中嵌入绘图

我让下面的函数做我想让它做的事情,除了不在新的工作表上生成图表,我想把它嵌入到写入数据的工作表中。另外,如何删除图例?我得到的是: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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值