새 워크 시트에서 차트를 생성하는 대신 워크 시트에 차트를 삽입하려는 경우를 제외하고는 다음과 같은 기능을 수행합니다. 데이터가 기록됩니다. 또한 전설을 어떻게 제거 할 수 있습니까? 여기에 내가있어 무엇 :Excel 2003의 워크 시트에 플롯을 파이썬을 사용하여 삽입하는 방법
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
기록 정확하게 당신이 원하는 것을 엑셀의 매크로에 그것을 변경할 수 있습니다 여기에
파이썬에 있다는 것입니다. 그런 다음 생성 된 코드를 COM 객체로 수행하는 방법에 대한 지침으로 사용하십시오. –
@Steven Rumbalski, 매크로 코드를 파이썬으로 변환 할 수있는 방법이 있습니까? 아니면 시행 착오를 통해 매크로 코드를 이해해야합니까? – Ben