In HYSYS, how do I export all of the material streams and their properties and…
- User
In HYSYS, how do I export all of the material streams and their properties and compositions as an excel file?
- Assistant
In HYSYS, how do I export all of the material streams and their properties and compositions as an excel file?
Exporting material streams and their properties and compositions from HYSYS to an Excel file involves several steps. Here is a comprehensive guide on how to do this:
Open the HYSYS Workbook:
Configure Streams Display:
Export to Excel:
Access Report Writer:
Create a New Report:
Configure Report:
Export the Report:
Open VBA (Visual Basic for Applications):
Create VBA Script for Export:
Sub ExportStreamsToExcel()
Dim hysysApp As Object
Dim hysysDoc As Object
Dim workbook As Excel.Workbook
Dim ws As Excel.Worksheet
Dim i As Integer
' Initialize HYSYS application and get the active document (case)
Set hysysApp = CreateObject("HYSYS.Application")
Set hysysDoc = hysysApp.ActiveDocument
' Create a new Excel workbook
Set workbook = Excel.Workbooks.Add
Set ws = workbook.Sheets(1)
' Add headers to the worksheet
ws.Cells(1, 1).Value = "Stream Name"
ws.Cells(1, 2).Value = "Property"
ws.Cells(1, 3).Value = "Value"
' Loop through all material streams and populate data
Dim streams As Object
Dim stream As Object
Dim propertyCount As Integer
Dim properties As Variant
Set streams = hysysDoc.Flowsheet.MaterialStreams
i = 2 ' Start adding data from the second row
For Each stream In streams
ws.Cells(i, 1).Value = stream.Name
' Get desired properties (e.g., temperature, pressure)
properties = Array("Temperature", "Pressure", "Flow")
propertyCount = 0
For Each prop In properties
ws.Cells(i + propertyCount, 2).Value = prop
ws.Cells(i + propertyCount, 3).Value = stream.GetProp(prop)
propertyCount = propertyCount + 1
Next prop
i = i + propertyCount
Next stream
' Save the Excel workbook
workbook.SaveAs "C:\Path_to_save\HYSYS_Stream_Data.xlsx"
workbook.Close
Set workbook = Nothing
' Cleanup
Set hysysDoc = Nothing
Set hysysApp = Nothing
End Sub
Run the Script:
In summary, HYSYS provides a few different methods to export stream data to Excel: using the built-in workbook feature, the report writer, or a custom VBA script. Choose the method that best suits your needs and preferences.
Not yet included in a published release.