diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/DayWhiteEmbryoEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/DayWhiteEmbryoEntity.cs index 95d33ba..3d4d385 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/DayWhiteEmbryoEntity.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/DayWhiteEmbryo/DayWhiteEmbryoEntity.cs @@ -1,5 +1,5 @@ using FreeSql.DataAnnotations; -using Microsoft.Office.Interop.Excel; + using System; using System.Collections.Generic; diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/ExportToPc.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/ExportToPc.cs index 0bc0ee5..0d59998 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/ExportToPc.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetWaitTime/ExportToPc.cs @@ -1,6 +1,6 @@ using DevExpress.ClipboardSource.SpreadsheetML; using Mesnac.Action.ChemicalWeighing.MainDetailControl.Entity; -using Microsoft.Office.Interop.Excel; + using System; using System.Collections.Generic; using System.Data; @@ -10,8 +10,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DataTable = System.Data.DataTable; -using Workbook = Microsoft.Office.Interop.Excel.Workbook; -using Worksheet = Microsoft.Office.Interop.Excel.Worksheet; + namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime { @@ -26,55 +25,16 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime { this.list = list; FileName = address; - this.ExportTo(); + } public Export(List list) { this.list = list; - this.ExportTo(); + } - public void ExportTo() - { - dt = new DataTable(); - dt.Columns.Add("机台", typeof(string)); - dt.Columns.Add("湿混等待时间", typeof(string)); - dt.Columns.Add("RGV等待时间", typeof(string)); - dt.Columns.Add("总等待时间", typeof(string)); - - MoreDataTable = new DataTable(); - MoreDataTable.Columns.Add("湿混等待时间", typeof(string)); - MoreDataTable.Columns.Add("RGV等待时间", typeof(string)); - MoreDataTable.Columns.Add("总等待时间", typeof(string)); - MoreDataTable.Columns.Add("起始时间", typeof(string)); - MoreDataTable.Columns.Add("结束时间", typeof(string)); - - // 使用 Microsoft Office Interop Excel 组件导出 Excel 文件 - Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application(); - Workbook workbook = excelApp.Workbooks.Add(); - - AllExport(workbook); - MoreDataExport(workbook); - - // 将 Excel 文件保存到磁盘 - try - { - workbook.SaveAs(this.FileName); - MessageBox.Show("导出成功!"); - } - catch(Exception e) - { - MessageBox.Show("请重新选择导出路径或关闭已打开的导出文件! " + e); - } - - // 关闭 Excel 应用程序和工作簿对象,并释放资源 - workbook.Close(); - excelApp.Quit(); - System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook); - System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp); - - } + /// /// 数据和导出 @@ -82,51 +42,13 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime /// private void AllExport(Workbook workbook) { - DataTableSum(); - Worksheet worksheet = (Worksheet)workbook.Worksheets[1]; - worksheet.Name = "总量统计"; - worksheet.Cells[1, 1] = "机台"; - worksheet.Cells[1, 2] = "湿混等待时间"; - worksheet.Cells[1, 3] = "RGV等待时间"; - worksheet.Cells[1, 4] = "总等待时间"; - int row = 2; - //读取数据 - foreach (DataRow item in dt.Rows) - { - worksheet.Cells[row, 1] = item[0]; - worksheet.Cells[row, 2] = item[1]; - worksheet.Cells[row, 3] = item[2]; - worksheet.Cells[row, 4] = item[3]; - row++; - } - System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet); + } //详细数据导出 private void MoreDataExport(Workbook workbook) { - for(int i = 1; i <= 8; i++) - { - MoreData(i); - Worksheet worksheet = (Worksheet)workbook.Worksheets.Add(); - worksheet.Name = "机台"+ i + "详细数据"; - worksheet.Cells[1, 1] = "湿混等待时间"; - worksheet.Cells[1, 2] = "RGV等待时间"; - worksheet.Cells[1, 3] = "总等待时间"; - worksheet.Cells[1, 4] = "发送接料信号时间"; - worksheet.Cells[1, 5] = "RGV离开时间"; - int row = 2; - foreach (DataRow item in MoreDataTable.Rows) - { - worksheet.Cells[row, 1] = item[0]; - worksheet.Cells[row, 2] = item[1]; - worksheet.Cells[row, 3] = item[2]; - worksheet.Cells[row, 4] = item[3]; - worksheet.Cells[row, 5] = item[4]; - row++; - } - System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet); - } + } /// diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 568d759..ecb82e1 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -172,6 +172,10 @@ False ..\..\..\PlugInPlatform\Mesnac.PlugIn.dll + + False + ..\..\..\A3Lib\Json\Newtonsoft.Json.dll + diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/ExportAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/ExportAction.cs index e5b774b..dd1701d 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/ExportAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DryMixer/ExportAction.cs @@ -3,7 +3,7 @@ using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.Entity.Report; -using Microsoft.Office.Interop.Excel; + using System; using System.Collections.Generic; using System.Linq; @@ -93,65 +93,6 @@ namespace Mesnac.Action.ChemicalWeighing.Report.DryMixer /// public void DataTabletoExcel(string strFileName, System.Data.DataTable tmpDataTable, DryMixerDos dryMixerDos) { - ///先得到datatable的行数 - int rowNum = tmpDataTable.Rows.Count; - ///列数 - int columnNum = tmpDataTable.Columns.Count; - ///声明一个应用程序类实例 - Microsoft.Office.Interop.Excel.Application xlApp = new ApplicationClass(); - - //创建一个新工作簿 - Workbook xlBook = xlApp.Workbooks.Add(); - ///在工作簿中得到sheet。 - _Worksheet oSheet = (_Worksheet)xlBook.Worksheets[1]; - - #region 绘制列 - - //绘制配方名和开始时间 - oSheet.Cells[1, 1] = "设备"; - oSheet.Cells[1, 2] = "Dos"; - oSheet.Cells[1, 3] = "批次号"; - oSheet.Cells[1, 4] = "物料代码"; - oSheet.Cells[1, 5] = "设定重量"; - oSheet.Cells[1, 6] = "设定公差"; - oSheet.Cells[1, 7] = "实际重量"; - oSheet.Cells[1, 8] = "实际公差"; - oSheet.Cells[1, 9] = "记录时间"; - oSheet.Cells[2, 1] = dryMixerDos.eqNo; - oSheet.Cells[2, 2] = dryMixerDos.dos; - oSheet.Cells[2, 3] = dryMixerDos.batch; - oSheet.Cells[2, 4] = dryMixerDos.matCode; - oSheet.Cells[2, 5] = dryMixerDos.setValue; - oSheet.Cells[2, 6] = dryMixerDos.setToler; - oSheet.Cells[2, 7] = dryMixerDos.actValue; - oSheet.Cells[2, 8] = dryMixerDos.setToler; - oSheet.Cells[2, 9] = dryMixerDos.recordTime; - - - - //自定义方法,绘制合并表头 - oSheet.Cells[3, 1] = "设备"; - oSheet.Cells[3, 2] = "Mix"; - oSheet.Cells[3, 3] = "批次"; - oSheet.Cells[3, 4] = "步号"; - oSheet.Cells[3, 5] = "动作"; - oSheet.Cells[3, 6] = "时间"; - oSheet.Cells[3, 7] = "温度"; - oSheet.Cells[3, 8] = "速度"; - oSheet.Cells[3, 9] = "记录时间"; - - #endregion - - //将DataTable中的数据导入Excel中 - for (int i = 0; i < rowNum; i++) - { - for (int j = 0; j < columnNum; j++) - { - ///excel中的列是从1开始的 - xlApp.Cells[i + 4, j + 1] = tmpDataTable.Rows[i][j].ToString(); - } - } - oSheet.SaveAs(strFileName); } /// diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/GelDoser/ExportAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/GelDoser/ExportAction.cs index 8ec56be..4d4f421 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/GelDoser/ExportAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/GelDoser/ExportAction.cs @@ -3,7 +3,7 @@ using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.Entity.Report; -using Microsoft.Office.Interop.Excel; + using System; using System.Collections.Generic; using System.Linq; @@ -93,65 +93,7 @@ namespace Mesnac.Action.ChemicalWeighing.Report.GelDoser /// public void DataTabletoExcel(string strFileName, System.Data.DataTable tmpDataTable, GelDoserDos_Water gelDoserDos) { - ///先得到datatable的行数 - int rowNum = tmpDataTable.Rows.Count; - ///列数 - int columnNum = tmpDataTable.Columns.Count; - ///声明一个应用程序类实例 - Microsoft.Office.Interop.Excel.Application xlApp = new ApplicationClass(); - - //创建一个新工作簿 - Workbook xlBook = xlApp.Workbooks.Add(); - ///在工作簿中得到sheet。 - _Worksheet oSheet = (_Worksheet)xlBook.Worksheets[1]; - - #region 绘制列 - - //绘制配方名和开始时间 - oSheet.Cells[1, 1] = "设备"; - oSheet.Cells[1, 2] = "Dos"; - oSheet.Cells[1, 3] = "批次号"; - oSheet.Cells[1, 4] = "物料代码"; - oSheet.Cells[1, 5] = "设定重量"; - oSheet.Cells[1, 6] = "设定公差"; - oSheet.Cells[1, 7] = "实际重量"; - oSheet.Cells[1, 8] = "实际公差"; - oSheet.Cells[1, 9] = "记录时间"; - oSheet.Cells[2, 1] = gelDoserDos.eqNo; - oSheet.Cells[2, 2] = gelDoserDos.dos; - oSheet.Cells[2, 3] = gelDoserDos.batch; - oSheet.Cells[2, 4] = gelDoserDos.matCode; - oSheet.Cells[2, 5] = gelDoserDos.setValue; - oSheet.Cells[2, 6] = gelDoserDos.setToler; - oSheet.Cells[2, 7] = gelDoserDos.actValue; - oSheet.Cells[2, 8] = gelDoserDos.setToler; - oSheet.Cells[2, 9] = gelDoserDos.recordTime; - - - - //自定义方法,绘制合并表头 - oSheet.Cells[3, 1] = "设备"; - oSheet.Cells[3, 2] = "Mix"; - oSheet.Cells[3, 3] = "批次"; - oSheet.Cells[3, 4] = "步号"; - oSheet.Cells[3, 5] = "动作"; - oSheet.Cells[3, 6] = "时间"; - oSheet.Cells[3, 7] = "温度"; - oSheet.Cells[3, 8] = "速度"; - oSheet.Cells[3, 9] = "记录时间"; - - #endregion - - //将DataTable中的数据导入Excel中 - for (int i = 0; i < rowNum; i++) - { - for (int j = 0; j < columnNum; j++) - { - ///excel中的列是从1开始的 - xlApp.Cells[i + 4, j + 1] = tmpDataTable.Rows[i][j].ToString(); - } - } - oSheet.SaveAs(strFileName); + } /// diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/ExportAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/ExportAction.cs index 3acf5da..b34d16d 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/ExportAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/WetMixer/ExportAction.cs @@ -3,7 +3,7 @@ using ICSharpCode.Core; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.Entity.Report; -using Microsoft.Office.Interop.Excel; + using System; using System.Collections.Generic; using System.Linq; @@ -86,51 +86,7 @@ namespace Mesnac.Action.ChemicalWeighing.Report.WetMixer /// public void DataTabletoExcel(string strFileName, System.Data.DataTable tmpDataTable, WetMixerDevice wetMixerDevice) { - ///先得到datatable的行数 - int rowNum = tmpDataTable.Rows.Count; - ///列数 - int columnNum = tmpDataTable.Columns.Count; - ///声明一个应用程序类实例 - Microsoft.Office.Interop.Excel.Application xlApp = new ApplicationClass(); - - //创建一个新工作簿 - Workbook xlBook = xlApp.Workbooks.Add(); - ///在工作簿中得到sheet。 - _Worksheet oSheet = (_Worksheet)xlBook.Worksheets[1]; - - #region 绘制列 - - //绘制配方名和开始时间 - oSheet.Cells[1, 1] = "设备"; - oSheet.Cells[1, 2] = "记录时间"; - oSheet.Cells[2, 1] = wetMixerDevice.eqNo; - oSheet.Cells[2, 2] = wetMixerDevice.recordTime; - - - - //自定义方法,绘制合并表头 - oSheet.Cells[3, 1] = "设备"; - oSheet.Cells[3, 2] = "Mix"; - oSheet.Cells[3, 3] = "批次"; - oSheet.Cells[3, 4] = "步号"; - oSheet.Cells[3, 5] = "动作"; - oSheet.Cells[3, 6] = "时间"; - oSheet.Cells[3, 7] = "温度"; - oSheet.Cells[3, 8] = "速度"; - oSheet.Cells[3, 9] = "记录时间"; - - #endregion - - //将DataTable中的数据导入Excel中 - for (int i = 0; i < rowNum; i++) - { - for (int j = 0; j < columnNum; j++) - { - ///excel中的列是从1开始的 - xlApp.Cells[i + 4, j + 1] = tmpDataTable.Rows[i][j].ToString(); - } - } - oSheet.SaveAs(strFileName); + } /// diff --git a/Main/MCRun/Program.cs b/Main/MCRun/Program.cs index 1e4ad01..a383a9d 100644 --- a/Main/MCRun/Program.cs +++ b/Main/MCRun/Program.cs @@ -7,8 +7,7 @@ using System.Linq; using System.Windows.Forms; using System.Xml; using ICSharpCode.Core; -using ICSharpCode.Core.Services; -using Mesnac.Action.ChemicalWeighing.FinishBatch; + using Mesnac.Gui.Run.Global; namespace MCRun {