1
duan
2024-08-21 f71a02229c1ba00fbecaead19256593ffb052753
提交 | 用户 | age
90c6eb 1 using NPOI.HSSF.UserModel;
J 2 using NPOI.SS.UserModel;
3 using System;
4 using System.Collections.Generic;
5 using System.Data;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
3ddf58 9 using DIXWeb.Entity.DIX;
6ac346 10 using DIXWeb.DAL;
90c6eb 11
3ddf58 12 namespace DIXWeb.Business.DIX
90c6eb 13 {
J 14     public class ToExcelTemplate:ExcelBaseNPOI
15     {
1bf8ef 16         public ToExcelTemplate() { }
90c6eb 17         public ToExcelTemplate(string filePath, string sheetName = "") : base(filePath, sheetName) { }
J 18
19         public static string FileName
20         {
21             get { return "ToDoList模板"; }
22         }
23
24         #region 重写样式 字典
25         protected override Dictionary<string, ICellStyle> createCellStyles(IWorkbook wb)
26         {
27             //return base.createCellStyles(wb);
28             Dictionary<string, ICellStyle> styles = new Dictionary<string, ICellStyle>();
29             IDataFormat df = wb.CreateDataFormat();
30             NPOI.SS.UserModel.IFont MsFont_9_Black_Font = wb.CreateFont();
31             MsFont_9_Black_Font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Normal;
32             SetFontHeight(MsFont_9_Black_Font, 9);
33             MsFont_9_Black_Font.FontName = "微软雅黑";
34
35             NPOI.SS.UserModel.IFont MsFont_9_Blue_Font = wb.CreateFont();
36             MsFont_9_Blue_Font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Normal;
37             MsFont_9_Blue_Font.Color = NPOI.HSSF.Util.HSSFColor.Blue.Index;
38             SetFontHeight(MsFont_9_Blue_Font, 9);
39             MsFont_9_Blue_Font.FontName = "微软雅黑";
40
41             NPOI.SS.UserModel.IFont MsFont_9_Red_Font = wb.CreateFont();
42             MsFont_9_Red_Font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Normal;
43             MsFont_9_Red_Font.Color = NPOI.HSSF.Util.HSSFColor.Red.Index;
44             SetFontHeight(MsFont_9_Red_Font, 9);
45             MsFont_9_Red_Font.FontName = "微软雅黑";
46
47
48             NPOI.SS.UserModel.ICellStyle cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
49             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
50             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
51             cellStyle.SetFont(MsFont_9_Black_Font);
52             cellStyle.WrapText = (true);
53             cellStyle.IsLocked = false;
54             styles.Add("微黑_9_V中H中_换行_全框细", cellStyle);
55
56             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
57             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Right;
58             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
59             cellStyle.SetFont(MsFont_9_Black_Font);
60             cellStyle.WrapText = (true);
61             cellStyle.IsLocked = false;
62             styles.Add("微黑_9_V中H右_换行_全框细", cellStyle);
63
64             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
65             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
66             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
67             cellStyle.SetFont(MsFont_9_Blue_Font);
68             cellStyle.WrapText = (true);
69             cellStyle.IsLocked = false;
70             styles.Add("微黑_9_V中H左_换行_全框细_蓝字", cellStyle);
71
72
73             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
74             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
75             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
76             cellStyle.SetFont(MsFont_9_Black_Font);
77             cellStyle.WrapText = (true);
78             cellStyle.IsLocked = true;  //上锁
79             styles.Add("微黑_9_V中H中_换行_全框细_上锁", cellStyle);
80
81             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
82             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
83             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
84             cellStyle.SetFont(MsFont_9_Red_Font);
85             cellStyle.WrapText = (true);
86             cellStyle.IsLocked = false;
87             styles.Add("微黑_红9_V中H中_换行_全框细", cellStyle);
88
89             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
90             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
91             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
92             cellStyle.SetFont(MsFont_9_Black_Font);
93             cellStyle.WrapText = (true);
94             cellStyle.IsLocked = false;
95             cellStyle.FillPattern = FillPattern.SolidForeground;
96             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.PaleBlue.Index;
97             styles.Add("微黑_9_V中H中_换行_全框细_蓝背景", cellStyle);
98
99             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
100             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
101             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
102             cellStyle.SetFont(MsFont_9_Black_Font);
103             cellStyle.WrapText = (true);
104             cellStyle.IsLocked = true;
105             cellStyle.FillPattern = FillPattern.SolidForeground;
106             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.PaleBlue.Index;
107             styles.Add("微黑_9_V中H中_换行_全框细_蓝背景_上锁", cellStyle);
108
109             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
110             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
111             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
112             cellStyle.SetFont(MsFont_9_Blue_Font);
113             cellStyle.WrapText = (true);
114             cellStyle.IsLocked = true;
115             cellStyle.FillPattern = FillPattern.SolidForeground;
116             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.PaleBlue.Index;
117             styles.Add("微黑_9蓝_V中H中_换行_全框细_蓝背景_上锁", cellStyle);
118
119             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
120             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Right;
121             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
122             cellStyle.SetFont(MsFont_9_Black_Font);
123             cellStyle.WrapText = (true);
124             cellStyle.IsLocked = false;
125             cellStyle.FillPattern = FillPattern.SolidForeground;
126             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BrightGreen.Index;
127             styles.Add("微黑_9_V中H右_换行_全框细_绿背景", cellStyle);
128
129             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
130             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
131             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
132             cellStyle.SetFont(MsFont_9_Black_Font);
133             cellStyle.WrapText = (true);
134             cellStyle.IsLocked = false;
135             cellStyle.FillPattern = FillPattern.SolidForeground;
136             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LemonChiffon.Index;
137             styles.Add("微黑_9_V中H中_换行_全框细_柠檬黄背景", cellStyle);
138
139             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
140             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Right;
141             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
142             cellStyle.SetFont(MsFont_9_Black_Font);
143             cellStyle.WrapText = (true);
144             cellStyle.IsLocked = false;
145             cellStyle.FillPattern = FillPattern.SolidForeground;
146             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LemonChiffon.Index;
147             styles.Add("微黑_9_V中H右_换行_全框细_柠檬黄背景", cellStyle);
148
149             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
150             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
151             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
152             cellStyle.SetFont(MsFont_9_Black_Font);
153             cellStyle.WrapText = (true);
154             cellStyle.IsLocked = true;
155             cellStyle.FillPattern = FillPattern.SolidForeground;
156             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LemonChiffon.Index;
157             styles.Add("微黑_9_V中H中_换行_全框细_柠檬黄背景_上锁", cellStyle);
158
159             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
160             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
161             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
162             cellStyle.SetFont(MsFont_9_Black_Font);
163             cellStyle.WrapText = (false);
164             cellStyle.IsLocked = false;
165             cellStyle.FillPattern = FillPattern.SolidForeground;
166             cellStyle.DataFormat = (df.GetFormat("m-d h:mm"));
167             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LemonChiffon.Index;
168             styles.Add("微黑_9_V中H中_不换行_全框细_柠檬黄背景_日期", cellStyle);
169
170             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
171             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
172             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
173             cellStyle.SetFont(MsFont_9_Black_Font);
174             cellStyle.WrapText = (true);
175             cellStyle.IsLocked = false;
176             cellStyle.FillPattern = FillPattern.SolidForeground;
177             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightTurquoise.Index;
178             styles.Add("微黑_9_V中H中_换行_全框细_淡蓝背景", cellStyle);
179
180
181             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
182             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
183             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
184             cellStyle.SetFont(MsFont_9_Black_Font);
185             cellStyle.WrapText = (false);
186             cellStyle.IsLocked = false;
187             cellStyle.FillPattern = FillPattern.SolidForeground;
188             cellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightTurquoise.Index;
189             cellStyle.DataFormat = (df.GetFormat("m-d h:mm"));
190             styles.Add("微黑_9_V中H中_不换行_全框细_淡蓝背景_日期", cellStyle);
191
192
193             NPOI.SS.UserModel.IFont Bold_13_Black_Font = wb.CreateFont();
194             Bold_13_Black_Font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold;
195             Bold_13_Black_Font.FontHeight = 13 * 20;      //字体高度,XLSX下有字体大小问题
196             //Bold_15_Black_Font.FontHeightInPoints = 10; //字体高度,XLS下有大小问题
197             Bold_13_Black_Font.FontName = "黑体";
198
199             NPOI.SS.UserModel.IFont Bold_15_Black_Font = wb.CreateFont();
200             Bold_15_Black_Font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold;
201             Bold_15_Black_Font.FontHeight = 15 * 20;      //字体高度,XLSX下有字体大小问题
202             //Bold_15_Black_Font.FontHeightInPoints = 10; //字体高度,XLS下有大小问题
203             Bold_15_Black_Font.FontName = "黑体";
204
205             NPOI.SS.UserModel.IFont MsFont_12_Black_Font = wb.CreateFont();
206             MsFont_12_Black_Font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Normal;
207             SetFontHeight(MsFont_12_Black_Font, 12);
208             MsFont_12_Black_Font.FontName = "微软雅黑";
209
210             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
211             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
212             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
213             cellStyle.SetFont(Bold_13_Black_Font);
214             //cellStyle.WrapText = (false);//换行
215             styles.Add("Bold_13_Black_Font", cellStyle);
216
217             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
218             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
219             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
220             cellStyle.SetFont(Bold_15_Black_Font);
221             //cellStyle.WrapText = (false);
222             styles.Add("Bold_15_Black_Font", cellStyle);
223
224
225             cellStyle = CreateBorderedStyle(wb, BorderStyle.Thin);
226             cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
227             cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
228             cellStyle.SetFont(MsFont_12_Black_Font);
229             //cellStyle.WrapText = (true);//换行
230             cellStyle.IsLocked = true;
231             styles.Add("微黑_12_V中H中_全框细_上锁", cellStyle);
232
233             return styles;
234         }
235         #endregion
236
237         #region 下载模板
238         public bool ExportTemplate(List<ExcelEntity> recordList)
239         {
240             #region Sheet基本设置
241             NPOI.SS.UserModel.ISheet sheet = hssfworkbook.CreateSheet(ExcelMainSheetName);
242             Dictionary<String, ICellStyle> styles = createCellStyles(hssfworkbook);
243             if (IsXlsx == false)
244                 sheet.TabColorIndex = NPOI.HSSF.Util.HSSFColor.CornflowerBlue.Index;
245             NPOI.SS.UserModel.IPrintSetup printSetup = sheet.PrintSetup;
246             sheet.DisplayGridlines = false;
247             SetDefaultRowHeight(sheet, 28.0F);
248
249             sheet.FitToPage = (true);
250             sheet.HorizontallyCenter = (true);  //设置Sheet缩放
251             sheet.SetZoom(82, 100);              // 100 percent magnification
252             SetColumnWidth(sheet, 00, 25.00);
253             SetColumnWidth(sheet, 01, 25.00);
254             SetColumnWidth(sheet, 02, 25.00);
255             SetColumnWidth(sheet, 03, 25.00);
256             SetColumnWidth(sheet, 04, 25.00);
257             SetColumnWidth(sheet, 05, 25.00);
258             SetColumnWidth(sheet, 06, 25.00);
259             SetColumnWidth(sheet, 07, 25.00);
260             SetColumnWidth(sheet, 08, 25.00);
261             SetColumnWidth(sheet, 09, 25.00);
262             SetColumnWidth(sheet, 10, 25.00);
263
264             sheet.SetColumnHidden(24, true);
265             #endregion
266
267             AddDropDownDataValidation(sheet, 1, 65535, 7, 7, new string[] { "量试", "量产", "实验" });
268
269             IRow curRow = sheet.CreateRow(0);
270             ICell curCel = null;
271             SetRowHeight(curRow, 33);//第一行行高
272             #region 第一行 列头
273             curCel = curRow.CreateCell(0);
274             SetColumnWidth(sheet, 00, 25.00);
275             curCel.SetCellValue("OPID");
276             curCel.CellStyle = styles["Bold_13_Black_Font"];
277
278             curCel = curRow.CreateCell(1);
279             SetColumnWidth(sheet, 01, 15.00);
280             curCel.SetCellValue("判定结果");
281             curCel.CellStyle = styles["Bold_13_Black_Font"];
282
283             curCel = curRow.CreateCell(2);
284             SetColumnWidth(sheet, 02, 15.00);
285             curCel.SetCellValue("线别");
286             curCel.CellStyle = styles["Bold_13_Black_Font"];
287
288             curCel = curRow.CreateCell(3);
289             SetColumnWidth(sheet, 03, 15.00);
290             curCel.SetCellValue("机台");
291             curCel.CellStyle = styles["Bold_13_Black_Font"];
292
293             curCel = curRow.CreateCell(4);
294             SetColumnWidth(sheet, 04, 15.00);
295             curCel.SetCellValue("机种");
296             curCel.CellStyle = styles["Bold_13_Black_Font"];
297
298             curCel = curRow.CreateCell(5);
299             SetColumnWidth(sheet, 05, 20.00);
300             curCel.SetCellValue("工位");
301             curCel.CellStyle = styles["Bold_13_Black_Font"];
302
303             curCel = curRow.CreateCell(6);
304             SetColumnWidth(sheet, 06, 15.00);
305             curCel.SetCellValue("拍照部位");
306             curCel.CellStyle = styles["Bold_13_Black_Font"];
307
308             curCel = curRow.CreateCell(7);
309             SetColumnWidth(sheet, 07, 25.00);
310             curCel.SetCellValue("画像链接");
311             curCel.CellStyle = styles["Bold_13_Black_Font"];
312
313             curCel = curRow.CreateCell(8);
314             SetColumnWidth(sheet, 08, 30.00);
315             curCel.SetCellValue("图片保存时间");
316             curCel.CellStyle = styles["Bold_13_Black_Font"];
317
318             curCel = curRow.CreateCell(9);
319             SetColumnWidth(sheet, 09, 10.00);
320             curCel.SetCellValue("拓展1");
321             curCel.CellStyle = styles["Bold_13_Black_Font"];
322
323             curCel = curRow.CreateCell(10);
324             SetColumnWidth(sheet, 10, 10.00);
325             curCel.SetCellValue("拓展2");
326             curCel.CellStyle = styles["Bold_13_Black_Font"];
327             #endregion
328
329             int row = 1;
330             int col = 0;
331             foreach (ExcelEntity item in recordList)
332             {
333                 col = 0;//重新初始化
334                 curRow = sheet.CreateRow(row++);
335
336                 curCel = curRow.CreateCell(col++);
337                 curCel.SetCellValue(item.OPID);
338                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
339
340                 curCel = curRow.CreateCell(col++);
341                 curCel.SetCellValue(item.Judge);
342                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
343
344                 curCel = curRow.CreateCell(col++);
345                 curCel.SetCellValue(item.Line);
346                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
347
348                 curCel = curRow.CreateCell(col++);
349                 curCel.SetCellValue(item.MtNo);
350                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
351
352                 curCel = curRow.CreateCell(col++);
353                 curCel.SetCellValue(item.Model);
354                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
355
356                 curCel = curRow.CreateCell(col++);
357                 curCel.SetCellValue(item.WorkStation);
358                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
359
360                 curCel = curRow.CreateCell(col++);
361                 curCel.SetCellValue(item.Part);
362                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
363
364                 curCel = curRow.CreateCell(col++);
365                 curCel.SetCellValue(item.FileName);
366                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
367                 HSSFHyperlink link = new HSSFHyperlink(HyperlinkType.Url);
368                 link.Address = item.FileName;
369                 curCel.Hyperlink = link;
370
371                 curCel = curRow.CreateCell(col++);
372                 curCel.SetCellValue(item.CreateTime);
373                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
374
375                 curCel = curRow.CreateCell(col++);
376                 curCel.SetCellValue(item.Extend1);
377                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
378
379                 curCel = curRow.CreateCell(col++);
380                 curCel.SetCellValue(item.Extend2);
381                 curCel.CellStyle = styles["微黑_12_V中H中_全框细_上锁"];
382             }
383
384             return WriteToFile(this.ExcelFilePath);
385         }
6ac346 386
A 387
388         public bool ExportTemplate()
389         {
390             #region Sheet基本设置
391             NPOI.SS.UserModel.ISheet sheet = hssfworkbook.CreateSheet(ExcelMainSheetName);
392             Dictionary<String, ICellStyle> styles = createCellStyles(hssfworkbook);
393             if (IsXlsx == false)
394                 sheet.TabColorIndex = NPOI.HSSF.Util.HSSFColor.CornflowerBlue.Index;
395             NPOI.SS.UserModel.IPrintSetup printSetup = sheet.PrintSetup;
396             sheet.DisplayGridlines = false;
397             SetDefaultRowHeight(sheet, 28.0F);
398
399             sheet.FitToPage = (true);
400             sheet.HorizontallyCenter = (true);  //设置Sheet缩放
401             sheet.SetZoom(82, 100);              // 100 percent magnification
402             SetColumnWidth(sheet, 00, 25.00);
403             SetColumnWidth(sheet, 01, 25.00);
404             SetColumnWidth(sheet, 02, 25.00);
405             SetColumnWidth(sheet, 03, 25.00);
406             SetColumnWidth(sheet, 04, 25.00);
407             SetColumnWidth(sheet, 05, 25.00);
408             SetColumnWidth(sheet, 06, 25.00);
409             SetColumnWidth(sheet, 07, 25.00);
410             SetColumnWidth(sheet, 08, 25.00);
411             SetColumnWidth(sheet, 09, 25.00);
412             SetColumnWidth(sheet, 10, 25.00);
413
414             sheet.SetColumnHidden(24, true);
415             #endregion
416
417             string[] orgArr = GetOrg();
418             string[] iotArr = GetInspectObjectType();
419             string[] iaArr = GetInspectArea();
420             string[] itArr = GetInspectType();
421             string[] ifArr = GetInspectFrequency();
422             string[] isArr = GetInspectStatu();
9057d4 423             string InspectObjectIsNeedStr = System.Configuration.ConfigurationManager.AppSettings["InspectObjectIsNeedStr"].ToString();
A 424             string[] iNArr = InspectObjectIsNeedStr.Split(',');
6ac346 425             AddDropDownDataValidation(sheet, 1, 65535, 0, 0, orgArr);
A 426             AddDropDownDataValidation(sheet, 1, 65535, 1, 1, iotArr);
427             AddDropDownDataValidation(sheet, 1, 65535, 4, 4, iaArr);
428             AddDropDownDataValidation(sheet, 1, 65535, 6, 6, itArr);
429             AddDropDownDataValidation(sheet, 1, 65535, 7, 7, ifArr);
430             AddDropDownDataValidation(sheet, 1, 65535, 8, 8, isArr);
9057d4 431             AddDropDownDataValidation(sheet, 1, 65535, 9, 9, iNArr);
6ac346 432
A 433             IRow curRow = sheet.CreateRow(0);
434             ICell curCel = null;
435             SetRowHeight(curRow, 33);//第一行行高
436             #region 第一行 列头
437             curCel = curRow.CreateCell(0);
438             SetColumnWidth(sheet, 00, 15.00);
439             curCel.SetCellValue("组织ID");
440             curCel.CellStyle = styles["Bold_13_Black_Font"];
441
442             curCel = curRow.CreateCell(1);
443             SetColumnWidth(sheet, 01, 25.00);
444             curCel.SetCellValue("设备类型ID");
445             curCel.CellStyle = styles["Bold_13_Black_Font"];
446
447             curCel = curRow.CreateCell(2);
448             SetColumnWidth(sheet, 02, 15.00);
449             curCel.SetCellValue("设备编号");
450             curCel.CellStyle = styles["Bold_13_Black_Font"];
451
452             curCel = curRow.CreateCell(3);
453             SetColumnWidth(sheet, 03, 15.00);
454             curCel.SetCellValue("设备名称");
455             curCel.CellStyle = styles["Bold_13_Black_Font"];
456
457             curCel = curRow.CreateCell(4);
458             SetColumnWidth(sheet, 04, 25.00);
459             curCel.SetCellValue("设备区域ID");
460             curCel.CellStyle = styles["Bold_13_Black_Font"];
461
462             curCel = curRow.CreateCell(5);
463             SetColumnWidth(sheet, 05, 15.00);
464             curCel.SetCellValue("设备位置");
465             curCel.CellStyle = styles["Bold_13_Black_Font"];
466
467             curCel = curRow.CreateCell(6);
468             SetColumnWidth(sheet, 06, 25.00);
469             curCel.SetCellValue("点检周期ID");
470             curCel.CellStyle = styles["Bold_13_Black_Font"];
471
472             curCel = curRow.CreateCell(7);
473             SetColumnWidth(sheet, 07, 20.00);
474             curCel.SetCellValue("点检频率ID");
475             curCel.CellStyle = styles["Bold_13_Black_Font"];
476
477             curCel = curRow.CreateCell(8);
478             SetColumnWidth(sheet, 08, 20.00);
479             curCel.SetCellValue("设备状态ID");
480             curCel.CellStyle = styles["Bold_13_Black_Font"];
481
482             curCel = curRow.CreateCell(9);
9057d4 483             SetColumnWidth(sheet, 09, 30.00);
A 484             curCel.SetCellValue("是否需要点检");
6ac346 485             curCel.CellStyle = styles["Bold_13_Black_Font"];
A 486
487             curCel = curRow.CreateCell(10);
488             SetColumnWidth(sheet, 10, 25.00);
9057d4 489             curCel.SetCellValue("导入日期");
6ac346 490             curCel.CellStyle = styles["Bold_13_Black_Font"];
A 491
492             curCel = curRow.CreateCell(11);
493             SetColumnWidth(sheet, 11, 25.00);
9057d4 494             curCel.SetCellValue("有效期(年)");
6ac346 495             curCel.CellStyle = styles["Bold_13_Black_Font"];
A 496
9057d4 497             //curCel = curRow.CreateCell(12);
A 498             //SetColumnWidth(sheet, 12, 10.00);
499             //curCel.SetCellValue("设备年限");
500             //curCel.CellStyle = styles["Bold_13_Black_Font"];
6ac346 501             #endregion
A 502             
503             return WriteToFile(this.ExcelFilePath);
504         }
90c6eb 505         #endregion
6ac346 506
A 507
1bf8ef 508         public string[] GetOrg() {
6ac346 509             List<string> list = new List<string>();
A 510             using (DBContext db = new DBContext())
511             {
1bf8ef 512                 list = db.Database.SqlQuery<string>("select CONVERT(varchar,Id)+'>'+[Name] as text from DIX.dbo.OrgInfo with(nolock) where parentId = 0 order by Id asc ").ToList();
6ac346 513             }
A 514             string[] arr = list.ToArray<string>();
515             return arr;
516         }
517
1bf8ef 518         public string[] GetInspectObjectType()
6ac346 519         {
1bf8ef 520             string GetInspectObjectTypeExcel = System.Configuration.ConfigurationManager.AppSettings["GetInspectObjectTypeExcel"].ToString();
6ac346 521             List<string> list = new List<string>();
A 522             using (DBContext db = new DBContext())
523             {
1bf8ef 524                 list = db.Database.SqlQuery<string>("meta.p_GetInspectObjectTypeExcel '"+ GetInspectObjectTypeExcel + "' ").ToList();
6ac346 525             }
A 526             string[] arr = list.ToArray<string>();
527             return arr;
528         }
529
1bf8ef 530         public string[] GetInspectArea()
6ac346 531         {
A 532             List<string> list = new List<string>();
533             using (DBContext db = new DBContext())
534             {
535                 list = db.Database.SqlQuery<string>("select CONVERT(varchar,Id)+'>'+[Name] as text from DIX.meta.InspectArea with(nolock) order by Id asc ").ToList();
536             }
537             string[] arr = list.ToArray<string>();
538             return arr;
539         }
540
1bf8ef 541         public string[] GetInspectType()
6ac346 542         {
A 543             List<string> list = new List<string>();
544             using (DBContext db = new DBContext())
545             {
546                 list = db.Database.SqlQuery<string>("select CONVERT(varchar,Id)+'>'+[Name] as text from DIX.meta.InspectType with(nolock) order by Id asc ").ToList();
547             }
548             string[] arr = list.ToArray<string>();
549             return arr;
550         }
551
1bf8ef 552         public string[] GetInspectFrequency()
6ac346 553         {
A 554             List<string> list = new List<string>();
555             using (DBContext db = new DBContext())
556             {
557                 list = db.Database.SqlQuery<string>("select CONVERT(varchar,Id)+'>'+Frequency as text from DIX.meta.InspectFrequency with(nolock) order by Id asc ").ToList();
558             }
559             string[] arr = list.ToArray<string>();
560             return arr;
561         }
562
1bf8ef 563         public string[] GetInspectStatu()
6ac346 564         {
A 565             List<string> list = new List<string>();
566             using (DBContext db = new DBContext())
567             {
568                 list = db.Database.SqlQuery<string>("select CONVERT(varchar,Id)+'>'+Status as text from DIX.meta.InspectObjectStatusInfo with(nolock) order by Id asc ").ToList();
569             }
570             string[] arr = list.ToArray<string>();
571             return arr;
572         }
573
90c6eb 574     }
J 575 }