|
@@ -1,5 +1,7 @@
|
|
|
using ConfigOperator;
|
|
|
using GeneralData;
|
|
|
+using NPOI.SS.UserModel;
|
|
|
+using NPOI.XSSF.UserModel;
|
|
|
using TemperatureConfigFile;
|
|
|
using Universal;
|
|
|
|
|
@@ -80,8 +82,10 @@ internal class Program
|
|
|
private static ChannelConfig GetChannelConfig(Dictionary<int, string> channel, int numerator, int denominator)
|
|
|
{
|
|
|
string[] content = [.. channel.Values];
|
|
|
- ChannelConfig config = new();
|
|
|
- config.Index = byte.Parse(content[1]);
|
|
|
+ ChannelConfig config = new()
|
|
|
+ {
|
|
|
+ Index = byte.Parse(content[1])
|
|
|
+ };
|
|
|
|
|
|
if (float.TryParse(content[2], out float setPoint))
|
|
|
{
|
|
@@ -144,8 +148,10 @@ internal class Program
|
|
|
private static ChannelConfig GetChannelConfig(Dictionary<int, string> channel)
|
|
|
{
|
|
|
string[] content = [.. channel.Values];
|
|
|
- ChannelConfig config = new();
|
|
|
- config.Index = byte.Parse(content[1]);
|
|
|
+ ChannelConfig config = new()
|
|
|
+ {
|
|
|
+ Index = byte.Parse(content[1])
|
|
|
+ };
|
|
|
|
|
|
if (float.TryParse(content[2], out float setPoint))
|
|
|
config.SetPoint = setPoint;
|
|
@@ -189,4 +195,44 @@ internal class Program
|
|
|
|
|
|
return config;
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+public class ExcelReader
|
|
|
+{
|
|
|
+ public static Dictionary<string, Dictionary<int, Dictionary<int, string>>> Read(string filePath, int startRow)
|
|
|
+ {
|
|
|
+ Dictionary<string, Dictionary<int, Dictionary<int, string>>> sheets = [];
|
|
|
+
|
|
|
+ using FileStream file = new(filePath, FileMode.Open, FileAccess.Read);
|
|
|
+
|
|
|
+ for (int i = 0; ; i++)
|
|
|
+ {
|
|
|
+ ISheet sheet;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ sheet = new XSSFWorkbook(file).GetSheetAt(i);
|
|
|
+ if (sheet is null)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Dictionary<int, Dictionary<int, string>> contents = [];
|
|
|
+ sheets[sheet.SheetName] = contents;
|
|
|
+
|
|
|
+ for (int row = startRow; row <= sheet.LastRowNum; row++)
|
|
|
+ {
|
|
|
+ if (sheet.GetRow(row) is not IRow currentRow)
|
|
|
+ continue;
|
|
|
+ contents[row] = [];
|
|
|
+ for (int colum = 0; colum < currentRow.LastCellNum; colum++)
|
|
|
+ {
|
|
|
+ ICell cell = currentRow.GetCell(colum);
|
|
|
+ contents[row][colum] = cell?.ToString() ?? string.Empty;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sheets;
|
|
|
+ }
|
|
|
+}
|