ConfigSupport 1.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package ConfigSupport --version 1.0.6                
NuGet\Install-Package ConfigSupport -Version 1.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ConfigSupport" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ConfigSupport --version 1.0.6                
#r "nuget: ConfigSupport, 1.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ConfigSupport as a Cake Addin
#addin nuget:?package=ConfigSupport&version=1.0.6

// Install ConfigSupport as a Cake Tool
#tool nuget:?package=ConfigSupport&version=1.0.6                

Excel Data Importer

The Excel Data Importer is a simple library for importing data from Excel files (.xlsx) into a .NET application. It provides a class ProcessExcel, which contains a method ImportExcelData for importing Excel data and ExcelToJSONConvertMethod for converting Excel data into formatted JSON string.

Installation

To use the Excel Data Importer in your .NET project, follow these steps:

Ensure you have all this library installed in your project. You can install it via NuGet using the following command:

  • Install-Package EPPlus
  • Install-Package Newtonsoft.Json
  • Install-Package ConfigSupport

Usage

using ConfigSupport;

OpcUaExcelJsonConverter Class:

The OpcUaExcelJsonConverter class provides a two methods

  • ConvertExcelToJson -- Convert Excel to JSON structure string
  • ConvertJsonToExcel -- Convert JSON to Excel / Json data with respect to the JSON

ConvertExcelToJson Method

The ConvertExcelToJson method import Excel data and converting it to JSON. Here's how you can use it:

Parameters:
  • filePath: Specify the path of your Excel file location with name.
  • subProcess: An array of string with all sub-Process.
  • dataType: An array of string with all Data Types.
  • descriptionPattern: Regex patter to check the description pattern.
Request:

CSharp:

class Program
{
    static void Main(string[] args)
    {
        OpcUaExcelJsonConverter yourClassInstance = new OpcUaExcelJsonConverter();
        string filePath = "example.xlsx"; // Specify the Excel file path
        string[] subProcess = new string[] { "SubProcess1", "SubProcess2", "SubProcess3" };
        string[] dataType = new string[] { "DataType1", "DataType2", "DataType3" };
        string descriptionPattern = "YourRegexPattern";

        string response = yourClassInstance.ConvertExcelToJson(string filePath, string[] subProcess, string[] dataType, string descriptionPattern);
        // Use the response as needed in your application
    }
}
Response:

The return as a JSON formatted string.

Example Response:

Type1: With Xml string
{
  "name": "string",
  "version": "string",
  "comment": "string",
  "instanceNamespaceUri": "string",
  "opcGatewayOptions": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  },
  "opcNodeConfig": [
    {
      "description": "string",
      "version": "string",
      "nameSpaceUri": "string",
      "opcNodes": [
        {
          "name": "string",
          "type": "string",
          "description": "string",
          "template": "string",
          "childTypes": [
            "string"
          ]
        }
      ],
      "xmlConfig": "string"
    }
  ]
}

Type:2 Without Xml string
{
  "name": "string",
  "version": "string",
  "comment": "string",
  "instanceNamespaceUri": "string",
  "opcGatewayOptions": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  },
  "opcNodeConfig": [
    {
      "description": "string",
      "version": "string",
      "nameSpaceUri": "string",
      "opcNodes": [
        {
          "name": "string",
          "type": "string",
          "description": "string",
          "template": "string",
          "childTypes": [
            "string"
          ]
        }
      ]
    }
  ]
}

ConvertJsonToExcel Method:

The ConvertJsonToExcel method import JSON data and converting it to Excel / JSON files with respect to the JSON request. Here's how you can use it:

Parameters:
  • opcNode: OPCNodeConfig Type data.
  • filePath: folder path to save the extracted files.
  • columnData: It refers to Excel column header information.
  • attributes: It refers to the list of attributes used in the files.
Example:
class Program
{
    public class OPCNodeConfig
    {
        public string description { get; set; }
        public string version { get; set; }
        public string nameSpaceUri { get; set; }
        public string xmlConfig { get; set; }
        public List<OPCNode> opcNodes { get; set; }
    }
    public class OPCNode
    {
        public string name { get; set; }
        public string type { get; set; }
        public string template { get; set; }
        public string description { get; set; }
        public List<OPCNode> childTypes { get; set; }
        public List<string> ObjectLevels { get; set; } = new List<string>();
    }
    static void Main(string[] args)
    {
        // Create an instance of your class
        OpcUaExcelJsonConverter yourClassInstance = new OpcUaExcelJsonConverter();

        // Prepare sample data
        OPCNodeConfig opcNode = new OPCNodeConfig();
        // Add sample data to opcNode

        string filePath = yourFilePath.json;
        List<string> columnData = new List<string> { "ColumnData1", "ColumnData2", "ColumnData3" };
        string[] attributes = new string[] { "Attributes1", "Attributes2", "Attributes3" };

        // Call the ExcelToJSONConvertMethod
        yourClassInstance.ConvertJsonToExcel(OPCNodeConfig opcNode, string filePath, List<string> columnData, string[] attributes)
    }
}
Return Value:

No return, it will save the file as Excel or Json in the give file path location

Example Response:

Type:1 JSON contains XML type configuration
File saved as
- HeaderJson.json
- xmlFile1.json
- xmlFile2.json ...

Type:2 JSON does not contains XML in the configuration
File saved as
- HeaderJson.json
- excelFile1.xlsx
- excelFile2.xlsx ...

Contributing

Contributions to the Excel Data Importer library are welcome!

License

This project is licensed under the MIT License

Author Information

SIVA SHANMUGA VADIVEL

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8 80 6/15/2024
1.0.6 70 6/11/2024
1.0.5 66 6/11/2024
1.0.4 61 6/7/2024
1.0.3 67 6/7/2024
1.0.2 71 6/7/2024
1.0.1 61 6/7/2024
1.0.0 63 6/7/2024

Updated Catch statement to catch the Excel File type