ConfigSupport 1.0.2
See the version list below for details.
dotnet add package ConfigSupport --version 1.0.2
NuGet\Install-Package ConfigSupport -Version 1.0.2
<PackageReference Include="ConfigSupport" Version="1.0.2" />
paket add ConfigSupport --version 1.0.2
#r "nuget: ConfigSupport, 1.0.2"
// Install ConfigSupport as a Cake Addin #addin nuget:?package=ConfigSupport&version=1.0.2 // Install ConfigSupport as a Cake Tool #tool nuget:?package=ConfigSupport&version=1.0.2
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;
Excel file to Data:
The ProcessExcel
class provides a method ImportExcelData
for importing Excel data. Here's how you can use it:
Parameters:
fileName
: Specify the name of your Excel file.folderPath
: Specify the folder path where your Excel file is located.
Example:
class Program
{
static void Main(string[] args)
{
ProcessExcel excelProcessor = new ProcessExcel();
string fileName = "example.xlsx"; // Specify the name of your Excel file
string folderPath = "path/to/your/excel/files"; // Specify the folder path where your Excel file is located
var importResponse = excelProcessor.ImportExcelData(fileName, folderPath);
// Use the importResponse as needed in your application
}
}
Return Value:
Return as instance of the ImportClassDataResponse class, containing the following properties:
ResponseString
: A string representing the response message. It is empty if there are no errors or issues during the import process.OPCSheetDictionaryData
: A dictionary containing the imported data extracted from the Excel file. Each key represents a sheet name, and its corresponding value is a list of string arrays representing the rows of data in that sheet. Example Response:
ImportClassDataResponse importResponse = new ImportClassDataResponse
{
ResponseString = "Data imported successfully.",
OPCSheetDictionaryData = new Dictionary<string, List<string[]>>
{
{
"Sheet1", new List<string[]>
{
new string[] { "Header1", "Header2", "Header3" },
new string[] { "Data1", "Data2", "Data3" },
new string[] { "Data4", "Data5", "Data6" }
}
},
{
"Sheet2", new List<string[]>
{
new string[] { "Header1", "Header2", "Header3" },
new string[] { "Data1", "Data2", "Data3" },
new string[] { "Data4", "Data5", "Data6" }
}
}
}
};
Excel data to Json:
The ProcessExcel
class provides a method ExcelToJSONConvertMethod
Converts Excel data to JSON format string.
Parameters:
opcSheetDictionaryData
: Data which is extracted from the Excel.subProcess
: An array of strings with all sub-processes.dataType
: An array of strings with all data types.descriptionPattern
: Regex pattern to check the description pattern.
Example:
class Program
{
static void Main(string[] args)
{
// Create an instance of your class
ProcessExcel yourClassInstance = new ProcessExcel();
// Prepare sample data
Dictionary<string, List<string[]>> opcSheetDictionaryData = new Dictionary<string, List<string[]>>();
// Add sample data to opcSheetDictionaryData
string[] subProcess = new string[] { "SubProcess1", "SubProcess2", "SubProcess3" };
string[] dataType = new string[] { "DataType1", "DataType2", "DataType3" };
string descriptionPattern = "YourRegexPattern";
// Call the ExcelToJSONConvertMethod
string jsonResult = yourClassInstance.ExcelToJSONConvertMethod(opcSheetDictionaryData, subProcess, dataType, descriptionPattern);
// Use the jsonResult as needed in your application
}
}
Return Value:
The return is a JSON
formatted string.
Example Response:
{
"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",
"addedToTree": true,
"description": "string",
"template": "string",
"childTypes": [
"string"
]
}
],
"xmlConfig": "string"
}
]
}
Contributing
Contributions to the Excel Data Importer library are welcome!
License
This project is licensed under the MIT License
Product | Versions 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. |
-
net8.0
- EPPlus (>= 7.1.3)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.