schangxiang@126.com
2025-09-17 ff43ddf18764629ff875478e4e47a7281cbd230a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//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;
//        }
 
 
//    }
//}