5
« on: November 06, 2024, 02:26:07 PM »
There will be a need for some basic coding to transfer from your PLC to a spreadsheet. AdvancedHMI is the tool that makes it easy to get the data from the PLC. To get the data into a spreadsheet, you will need a tool for that. In the past, I would always recommend EPPlus as the tool. For new projects, I now suggest ClosedXML. That library is free and can be added to your project using Nuget.
Here is a simple demo of using ClosedXML:
1) After opening AdvancedHMI is Visual Studio, in Solution Explorer, click once on the AdvancedHMI project to make it the current selection
2) Go to Project -> Manage Nuget packages
3) At the top of the NUget windows, click Browse (Next to installed)
4) In the search bar, enter "ClosedXML"
5) ClosedXML should be the first item in the list, click once to highlight it.
6) To the right, click the install button
7) Accept the project additions and licenses
This will now have ClosedXML added to your project
Now let's put it to use:
1) In Solution Explorer, double click MainForm to open the designer
2) In a blank area on the MainForm, double click to get back to the code
3) Enter this code:
Dim WB As New ClosedXML.Excel.XLWorkbook()
WB.AddWorksheet()
WB.Worksheets(0).Cell("A2").Value = "New Value"
WB.SaveAs(".\ExcelFile2.xlsx")
4) Run the application, after it starts up then close it
At this point you now have created a Worksheet and added a value to cell A2.
1) In Solution Explorer, right click the AdvancedHMI project and select Open Folder in File Explorer
2) Browse to \bin\Debug
3) You should see the newly created file of ExcelFile2.xlsx
I will follow up later with another post on how to get data from your PLC