我有一个数组中的数据(B=1,2,3,4,5),我从DataTable中获取,我尝试使用以下代码将python for循环导入到excel文件中:
def Cells(a,b):
return str(chr(b+96) + str(a))
import clr
clr.AddReference("Microsoft.Office.Interop.Excel")
import Microsoft.Office.Interop.Excel as Excel
ex = Excel.ApplicationClass()
ex.Visible = True
workbook = ex.Workbooks.Open(r"F:\Programming\Excel\Plot data.xlsx")
worksheet=workbook.worksheets("Sheet1")
Adding_Max_Principal_Stress=Model.Analyses[0].Solution.AddMaximumPrincipalStress()
Model.Analyses[0].Solution.EvaluateAllResults()
A=Adding_Max_Principal_Stress.PlotData
B=A.Values[1]
C=B.Count
for i in range (C):
E=B[i]
worksheet.range(Cells(1+i,1)).Value=E在此代码中,B包含数据列表,如B=1,2,3,4,5、...B中的项目有100000个数据(数组值),在excel中导入数据需要5小时。有没有可能我可以加速这个过程。
发布于 2021-04-28 18:08:05
我猜IronPython不支持太多不同的Python库?在哪种情况下,代码需要几乎是纯python?
https://stackoverflow.com/questions/67175740
复制相似问题