|
|
@ -1,6 +1,6 @@
|
|
|
|
using DevExpress.ClipboardSource.SpreadsheetML;
|
|
|
|
using DevExpress.ClipboardSource.SpreadsheetML;
|
|
|
|
using Mesnac.Action.ChemicalWeighing.MainDetailControl.Entity;
|
|
|
|
using Mesnac.Action.ChemicalWeighing.MainDetailControl.Entity;
|
|
|
|
using Microsoft.Office.Interop.Excel;
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Data;
|
|
|
|
using System.Data;
|
|
|
@ -10,8 +10,7 @@ using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using DataTable = System.Data.DataTable;
|
|
|
|
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
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -26,55 +25,16 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.list = list;
|
|
|
|
this.list = list;
|
|
|
|
FileName = address;
|
|
|
|
FileName = address;
|
|
|
|
this.ExportTo();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Export(List<Lj_RGVTimeRecord> list)
|
|
|
|
public Export(List<Lj_RGVTimeRecord> list)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 数据和导出
|
|
|
|
/// 数据和导出
|
|
|
@ -82,51 +42,13 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport.WetWaitTime
|
|
|
|
/// <param name="workbook"></param>
|
|
|
|
/// <param name="workbook"></param>
|
|
|
|
private void AllExport(Workbook workbook)
|
|
|
|
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)
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|