添加使用EXCEL的功能

This commit is contained in:
gongxh
2022-06-10 09:42:29 +08:00
parent 163b60d144
commit de8fd63d02
8 changed files with 99 additions and 15 deletions

View File

@@ -27,8 +27,10 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NModbus" Version="3.0.72" /> <PackageReference Include="NModbus" Version="3.0.72" />
<PackageReference Include="NModbus.Serial" Version="3.0.72" /> <PackageReference Include="NModbus.Serial" Version="3.0.72" />
<PackageReference Include="NPOI" Version="2.5.6" />
<PackageReference Include="Osklib.WinForms" Version="1.6.0" /> <PackageReference Include="Osklib.WinForms" Version="1.6.0" />
<PackageReference Include="Scriban" Version="5.4.6" /> <PackageReference Include="Scriban" Version="5.4.6" />
<PackageReference Include="Snail.Utils.Office" Version="1.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -79,12 +81,21 @@
<None Update="Lang\en-US.json"> <None Update="Lang\en-US.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="Lang\en-US.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Lang\es-MX.json"> <None Update="Lang\es-MX.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="Lang\es-MX.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Lang\zh-CN.json"> <None Update="Lang\zh-CN.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="Lang\zh-CN.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Properties\Settings.settings"> <None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@@ -3832,7 +3832,7 @@
{ {
"formCode": "frmMainNew", "formCode": "frmMainNew",
"controlCode": "DayReport", "controlCode": "DayReport",
"controlName": "Day report" //Daily report "controlName": "Day report"
}, },
{ {
@@ -3882,7 +3882,7 @@
{ {
"formCode": "frmMainNew", "formCode": "frmMainNew",
"controlCode": "OperatorReport", "controlCode": "OperatorReport",
"controlName": "Operator report" //Operator report "controlName": "Operator report"
}, },
{ {
"formCode": "frmOperatorReport", "formCode": "frmOperatorReport",

Binary file not shown.

View File

@@ -4073,7 +4073,7 @@
{ {
"formCode": "frmMainNew", "formCode": "frmMainNew",
"controlCode": "DayReport", "controlCode": "DayReport",
"controlName": "Day report" //Daily report "controlName": "Day report"
}, },
{ {
@@ -4123,7 +4123,7 @@
{ {
"formCode": "frmMainNew", "formCode": "frmMainNew",
"controlCode": "OperatorReport", "controlCode": "OperatorReport",
"controlName": "Operator report" //Operator report "controlName": "Operator report"
}, },
{ {
"formCode": "frmOperatorReport", "formCode": "frmOperatorReport",
@@ -5936,5 +5936,4 @@
"controlCode": "PlcItemConfig", "controlCode": "PlcItemConfig",
"controlName": "PlcItemConfig" "controlName": "PlcItemConfig"
} }
] ]

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,6 @@
using CleanMachine.Model; //#define USE_JSON
using CleanMachine.Model;
using CleanMachine.Model.BAS; using CleanMachine.Model.BAS;
using CleanMachine.Model.CM; using CleanMachine.Model.CM;
using CleanMachineHMI.Domain.Enums; using CleanMachineHMI.Domain.Enums;
@@ -316,9 +318,27 @@ namespace CleanMachineHMI
if (ThemeLanguage == null || ThemeLanguage.Count == 0) if (ThemeLanguage == null || ThemeLanguage.Count == 0)
{ {
// var appPath = System.Windows.Forms.Application.StartupPath.Split(new string[] { @"bin\Debug" }, StringSplitOptions.RemoveEmptyEntries)[0]; // var appPath = System.Windows.Forms.Application.StartupPath.Split(new string[] { @"bin\Debug" }, StringSplitOptions.RemoveEmptyEntries)[0];
#if USE_JSON
var filePath = $"Lang\\{Global.LanguageCode}.json"; var filePath = $"Lang\\{Global.LanguageCode}.json";
var str = File.ReadAllText(filePath); var str = File.ReadAllText(filePath);
var lstLanguage = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ThemeLanguage>>(str); var lstLanguage = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ThemeLanguage>>(str);
#else
var filePath = $"Lang\\{Global.LanguageCode}.xlsx";
using (var fiel = new FileStream(filePath, FileMode.Open))
{
var lstLanguage = Snail.Utils.Office.Excel.ExcelImport.GetModels<ThemeLanguage>(fiel).ToList();
#endif
var tmpThemeLanguage = new Dictionary<string, string>(); var tmpThemeLanguage = new Dictionary<string, string>();
lstLanguage.ForEach(item => lstLanguage.ForEach(item =>
@@ -356,6 +376,9 @@ namespace CleanMachineHMI
//} //}
}); });
ThemeLanguage = tmpThemeLanguage; ThemeLanguage = tmpThemeLanguage;
#if !USE_JSON
}
#endif
} }
} }

51
nuget.config Normal file
View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<!--
Used to specify the default location to expand packages.
See: nuget.exe help install
See: nuget.exe help update
In this example, %PACKAGEHOME% is an environment variable. On Mac/Linux,
use $PACKAGE_HOME/External as the value.
-->
<add key="repositoryPath" value="%PACKAGEHOME%\External" />
<!--
Used to specify default source for the push command.
See: nuget.exe help push
-->
<add key="defaultPushSource" value="https://MyRepo/ES/api/v2/package" />
</config>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="snailRepo" value="http://10.20.88.96:8081/repository/nuget-group/" />
</packageSources>
<packageSourceCredentials>
<snailRepo>
<add key="Username" value="admin" />
<add key="ClearTextPassword" value="gonzo1982" />
</snailRepo>
</packageSourceCredentials>
-->
</configuration>