//using iWareCC.Common;
|
//using iWareCommon.Utils;
|
//using iWareSql.MyDbContext;
|
//using OfficeOpenXml;
|
//using OfficeOpenXml.Drawing;
|
//using System;
|
//using System.Collections.Generic;
|
//using System.IO;
|
//using System.Threading;
|
|
//namespace autuPrint.printService
|
//{
|
// public class CreatExcelForMail
|
// {
|
// /// <summary>
|
// /// //线程锁防止并发
|
// /// </summary>
|
// private static Mutex single = new Mutex();
|
// /// <summary>
|
// /// 生成打印数据源
|
// /// </summary>
|
// /// <param name="img">条形码</param>
|
// /// <param name="label">标签参数</param>
|
// /// <returns>成功返回true</returns>
|
// public static bool creatEXcel(List<v_ware_stock_early_warming> dataList, ref string realFilePath, ref string errMsg)
|
// {
|
// if (single.WaitOne())//增加线程锁防止双击并发
|
// {
|
|
// try
|
// {
|
// //获取模板文件
|
// realFilePath = SystemValueUtil.TEMPORARY_MAILWARNING_DIR + @"\库存预警信息(" + DateTime.Now.ToString("yyyy-MM-dd") + ").xlsx";
|
// FileInfo copyFile = new FileInfo(SystemValueUtil.TEMPORARY_MAILWARNING_FILEPATH);
|
// copyFile.CopyTo(realFilePath, true);
|
// FileInfo existingFile = new FileInfo(realFilePath);
|
// using (ExcelPackage package = new ExcelPackage(existingFile))
|
// {
|
// //获取模板内容
|
// ExcelWorksheet worksheet = package.Workbook.Worksheets["Sheet1"];
|
// //行,列
|
// //注意:行和列都是从1开始,而不是从0开始!!!
|
|
// for (int i = 0; i < (dataList.Count); i++)
|
// {
|
// worksheet.Cells[i + 2, 1].Value = dataList[i].Code;//物料编号
|
// worksheet.Cells[i + 2, 2].Value = dataList[i].Name;//物料名称
|
// worksheet.Cells[i + 2, 3].Value = dataList[i].Quantity;//库存数量
|
// worksheet.Cells[i + 2, 4].Value = dataList[i].Miniquantity;//最小库存预警值
|
// worksheet.Cells[i + 2, 5].Value = dataList[i].Maxquantity;//最大库存预警值
|
// }
|
|
|
// package.Save();//保存
|
// }
|
// }
|
// catch (Exception ex)
|
// {
|
// Log4NetHelper.WriteErrorLog(LogType.SrmTheadService, "类名: creatExcelPrint 方法名: creatEXcel 生成打印文件出错 \r\n " + ex.ToString(), ex);
|
// //logtxt.txtWrite("类名: creatExcelPrint 方法名: creatEXcel 生成打印文件出错 \r\n " + ex.ToString(), 2);
|
// errMsg = ex.Message;
|
// return false;
|
// }
|
// finally { single.ReleaseMutex(); }//一轮结束
|
// }
|
// return true;
|
// }
|
|
|
// }
|
//}
|