hysys物料输出EXCEL工具? 会用vba的话,要用excel检索hysys结果实际上很简单,比如 dim hycase as object sub connecthysys() on error goto errortrap set hyapp = getobject(, "hysys.application") set hycase = hyapp.activedocument if hycase is nothing then msgbox "a hysys simulation case must be open." exit sub end if clear getstreamdata exit sub errortrap: if err = 429 or err = 483 then msgbox "hysys is not currently running." else msgbox "the following error (" & err & ") occurred: " & error(err) end if end sub sub openhysys() ' set hyapp = getobject(, "hysys.application") ' if err = 483 then msgbox "hysys is not running." on error goto errortrap casename = application.getopenfilename("hysys simulation case (*.hsc), *.hsc") if casename = "false" then exit sub end if set hycase = getobject(casename, "hysys.simulationcase") getstreamdata hycase.close exit sub errortrap: msgbox "the following error occurred: " & error(err), buttons:=48 end sub 'get hysys stream data sub getstreamdata() on error goto errortrap dim hystreams as object dim hystream as processstream dim xlsheet as worksheet dim hyfluid as fluid dim optionbuttons as optionbuttons dim optionbutton as optionbutton dim sivalue as boolean set hystreams = hycase.flowsheet.materialstreams set xlsheet = worksheets("stream data") set optionbuttons = worksheets("main").optionbuttons clear for each optionbutton in optionbuttons if optionbutton.value = xlon then exit for next with xlsheet i = 0 for each hystream in hystreams .cells(3 + i, 1) = hystream.name .cells(3 + i, 2) = format(hystream.vapourfractionvalue, "0.###") .cells(3 + i, 3) = format(hystream.temperature.getvalue("k"), "##.###") .cells(3 + i, 4) = format(hystream.pressure.getvalue("kg/cm2"), "0.###") .cells(3 + i, 5) = format(hystream.pressure.getvalue("bar"), "0.###") .cells(3 + i, 6) = format(hystream.molarflow.getvalue("nm3/h(gas)"), "0.##") .cells(3 + i, 7) = format(ponentmolarfraction.values(0), "0.000000") .cells(3 + i, 8) = format(ponentmolarfraction.values(1), "0.000000") .cells(3 + i, 9) = format(ponentmolarfraction.values(2), "0.000000") .cells(3 + i, 10) = format(hystream.actualvolumeflow.getvalue("m3/h"), "0.##") .cells(3 + i, 11) = format(hystream.massflow.getvalue("kg/h"), "0.##") .cells(3 + i, 12) = format(hystream.cpcv, "0.####") if pressibility 0 then .cells(3 + i, 13) = format(pressibility, "0.#####") else .cells(3 + i, 13) = "n/a" end if if hystream.viscosity 0 then .cells(3 + i, 14) = format(hystream.viscosity, "0.#####") else .cells(3 + i, 14) = "n/a" end if .cells(3 + i, 15) = format(hystream.massdensity.getvalue("kg/m3"), "0.###") set hyfluid = hystream.duplicatefluid on error resume next .cells(3 + i, 17) = format(hyfluid.bubblepointpressurevalue / 100, "0.000") i = i + 1 next hystream set hystreams = hycase.flowsheet.energystreams for each hystream in hystreams .cells(3 + i, 1) = " " + hystream.name .cells(3 + i, 4) = "kw" .cells(3 + i, 3) = format(hystream.power, "#.#") i = i + 1 next hystream xlsheet.select selection.sort key1:=range("a3"), order1:=xlascending, header:=xlguess, _ ordercustom:=1, matchcase:=false, orientation:=xltoptobottom, sortmethod _ :=xlpinyin end with exit sub errortrap: msgbox "the following error occurred: " & error(err), buttons:=48 end sub 以上代码各个版本hysys都能使用,当然你需要先建立一个相应的excel页。查看更多