1212
This commit is contained in:
parent
569205fa76
commit
aa8fe6b2b7
Binary file not shown.
|
@ -74,7 +74,7 @@
|
|||
</f:DropDownList>
|
||||
<f:ToolbarFill runat="server"></f:ToolbarFill>
|
||||
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" ToolTip="导出" Icon="FolderUp"
|
||||
EnableAjax="false" DisableControlBeforePostBack="false" Hidden="true">
|
||||
EnableAjax="false" DisableControlBeforePostBack="false">
|
||||
</f:Button>
|
||||
</Items>
|
||||
</f:Toolbar>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using BLL;
|
||||
using BLL.Common;
|
||||
using BLL.CQMS.Comprehensive;
|
||||
using FineUIPro.Web.AttachFile;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.Streaming.Values;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -11,6 +13,7 @@ using System.Data.SqlClient;
|
|||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Services.Description;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||
|
||||
namespace FineUIPro.Web.Transfer
|
||||
|
@ -387,7 +390,7 @@ namespace FineUIPro.Web.Transfer
|
|||
ShowNotify("没有要导出的数据!!!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
newUrl = uploadfilepath.Replace("导出模板","导出数据").Replace(".xlsx",DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx");
|
||||
newUrl = uploadfilepath.Replace("导出模板", "导出数据").Replace(".xlsx", DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx");
|
||||
File.Copy(uploadfilepath, newUrl);
|
||||
NPOI.SS.UserModel.IWorkbook workbook;
|
||||
using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read))
|
||||
|
@ -395,64 +398,154 @@ namespace FineUIPro.Web.Transfer
|
|||
workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream);
|
||||
}
|
||||
|
||||
NPOI.SS.UserModel.ICellStyle cellStyleC = workbook.CreateCellStyle();
|
||||
cellStyleC.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyleC.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyleC.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyleC.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyleC.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
|
||||
cellStyleC.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
|
||||
cellStyleC.WrapText = true;
|
||||
|
||||
NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);
|
||||
|
||||
var pcList = Funs.DB.AttachFile.Where(p => p.MenuId == BLL.Const.PunchlistFromMenuId && p.AttachUrl != null && p.AttachUrl != "").ToList();
|
||||
|
||||
int i = 2;
|
||||
foreach (DataRow tbRow in tb.Rows)
|
||||
{
|
||||
string Id = tbRow["Id"].ToString();
|
||||
|
||||
NPOI.SS.UserModel.IRow row = sheet.CreateRow(i);
|
||||
NPOI.SS.UserModel.ICell cell;
|
||||
cell = row.CreateCell(0);
|
||||
cell.SetCellValue(tbRow["Num_NO"]==null?"": tbRow["Num_NO"].ToString());
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Num_NO"] == null ? "" : tbRow["Num_NO"].ToString());
|
||||
cell = row.CreateCell(1);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["System_No"] == null ? "" : tbRow["System_No"].ToString());
|
||||
cell = row.CreateCell(2);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Sub_Sys_No"] == null ? "" : tbRow["Sub_Sys_No"].ToString());
|
||||
cell = row.CreateCell(3);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["DESCRIPTION"] == null ? "" : tbRow["DESCRIPTION"].ToString());
|
||||
|
||||
//Photoes附件
|
||||
var photoesUrl = pcList.FirstOrDefault(p => p.ToKeyId == $"{Id}_A");
|
||||
if (photoesUrl != null && !string.IsNullOrWhiteSpace(photoesUrl.AttachUrl))
|
||||
{
|
||||
string[] arrUrl = photoesUrl.AttachUrl.Split(',');
|
||||
sheet.SetColumnWidth(4, 30 * 256);
|
||||
row.Height = (short)(90 * 20 * arrUrl.Length);
|
||||
foreach (string url in arrUrl)
|
||||
{
|
||||
var oneUrl = Server.MapPath("~/") + url;
|
||||
byte[] bytes = System.IO.File.ReadAllBytes(oneUrl);
|
||||
int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
|
||||
|
||||
// 第三步:创建画部
|
||||
IDrawing patriarch = sheet.CreateDrawingPatriarch();
|
||||
// 第四步:设置锚点
|
||||
int rowline = 1; // y方向
|
||||
// 参数说明:(在起始单元格的X坐标0-1023,Y的坐标0-255,在终止单元格的X坐标0-1023,Y的坐标0-255,起始单元格列数,行数,终止单元格列数,行数)
|
||||
IClientAnchor anchor = patriarch.CreateAnchor(0, 0, 0, 0, 4, i, 5, i + 1);
|
||||
// 第五步:把图片插到相应的位置+1
|
||||
IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
|
||||
//就取第一张,如果后期想取全部 那把下面这个跳出语句去掉
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cell = row.CreateCell(5);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Cat"] == null ? "" : tbRow["Cat"].ToString());
|
||||
cell = row.CreateCell(6);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Raised_By"] == null ? "" : tbRow["Raised_By"].ToString());
|
||||
cell = row.CreateCell(7);
|
||||
cell.SetCellValue(tbRow["Date_Raised"] == DBNull.Value ? "" :Convert.ToDateTime(tbRow["Date_Raised"]).ToString("yyyy-MM-dd"));
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Date_Raised"] == DBNull.Value ? "" : Convert.ToDateTime(tbRow["Date_Raised"]).ToString("yyyy-MM-dd"));
|
||||
cell = row.CreateCell(8);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Disc"] == null ? "" : tbRow["Disc"].ToString());
|
||||
cell = row.CreateCell(9);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["IsEngStr"] == null ? "" : tbRow["IsEngStr"].ToString());
|
||||
cell = row.CreateCell(10);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["IsMatIStr"] == null ? "" : tbRow["IsMatIStr"].ToString());
|
||||
cell = row.CreateCell(11);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Punch_Type"] == null ? "" : tbRow["Punch_Type"].ToString());
|
||||
cell = row.CreateCell(12);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Required_Date"] == DBNull.Value ? "" : Convert.ToDateTime(tbRow["Required_Date"]).ToString("yyyy-MM-dd"));
|
||||
cell = row.CreateCell(13);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Action_By"] == null ? "" : tbRow["Action_By"].ToString());
|
||||
cell = row.CreateCell(14);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["PIC"] == null ? "" : tbRow["PIC"].ToString());
|
||||
cell = row.CreateCell(15);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["PIC_WUH"] == null ? "" : tbRow["PIC_WUH"].ToString());
|
||||
cell = row.CreateCell(16);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Correction_Action"] == null ? "" : tbRow["Correction_Action"].ToString());
|
||||
|
||||
//CorrectedPhotos附件
|
||||
var correctedPhotosUrl = pcList.FirstOrDefault(p => p.ToKeyId == $"{Id}_B");
|
||||
if (correctedPhotosUrl != null && !string.IsNullOrWhiteSpace(correctedPhotosUrl.AttachUrl))
|
||||
{
|
||||
string[] arrUrl = correctedPhotosUrl.AttachUrl.Split(',');
|
||||
sheet.SetColumnWidth(17, 30 * 256);
|
||||
row.Height = (short)(90 * 20);
|
||||
foreach (string url in arrUrl)
|
||||
{
|
||||
var oneUrl = Server.MapPath("~/") + url;
|
||||
byte[] bytes = System.IO.File.ReadAllBytes(oneUrl);
|
||||
int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
|
||||
|
||||
// 第三步:创建画部
|
||||
IDrawing patriarch = sheet.CreateDrawingPatriarch();
|
||||
// 第四步:设置锚点
|
||||
int rowline = 1; // y方向
|
||||
// 参数说明:(在起始单元格的X坐标0-1023,Y的坐标0-255,在终止单元格的X坐标0-1023,Y的坐标0-255,起始单元格列数,行数,终止单元格列数,行数)
|
||||
IClientAnchor anchor = patriarch.CreateAnchor(0, 0, 0, 0, 17, i, 18, i + 1);
|
||||
// 第五步:把图片插到相应的位置+1
|
||||
IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
|
||||
//就取第一张,如果后期想取全部 那把下面这个跳出语句去掉
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cell = row.CreateCell(18);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Actual_Date"] == DBNull.Value ? "" : Convert.ToDateTime(tbRow["Actual_Date"]).ToString("yyyy-MM-dd"));
|
||||
cell = row.CreateCell(19);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Cleared_By"] == null ? "" : tbRow["Cleared_By"].ToString());
|
||||
cell = row.CreateCell(20);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Cleared_Date"] == DBNull.Value ? "" : Convert.ToDateTime(tbRow["Cleared_Date"]).ToString("yyyy-MM-dd"));
|
||||
cell = row.CreateCell(21);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Confirmed_By"] == null ? "" : tbRow["Confirmed_By"].ToString());
|
||||
cell = row.CreateCell(22);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Confirmed_Date"] == DBNull.Value ? "" : Convert.ToDateTime(tbRow["Confirmed_Date"]).ToString("yyyy-MM-dd"));
|
||||
cell = row.CreateCell(23);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Verified_By"] == null ? "" : tbRow["Verified_By"].ToString());
|
||||
cell = row.CreateCell(24);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Verified_Date"] == DBNull.Value ? "" : Convert.ToDateTime(tbRow["Verified_Date"]).ToString("yyyy-MM-dd"));
|
||||
cell = row.CreateCell(25);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Status"] == null ? "" : tbRow["Status"].ToString());
|
||||
cell = row.CreateCell(26);
|
||||
cell.CellStyle = cellStyleC;
|
||||
cell.SetCellValue(tbRow["Remark"] == null ? "" : tbRow["Remark"].ToString());
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue