using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Resources; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; using System.Xml; using Microsoft.VisualBasic; using Microsoft.VisualBasic.CompilerServices; using static iMESCore.Base.iMESComXML; using static iMESCore.Base.iMESConst; using NPOI.SS.UserModel; using NPOI.SS.Util; using NPOI.XSSF.UserModel; using NPOI.HSSF.UserModel; using static iMESCore.Base.iMESComSubroutine; namespace AutoRunLib { static class modAutoRunLibrary { public enum GroupType { UserGroup = 0, // 使用者群組 IssueGroup = 1, // 簽核群組 EquipmentGroup = 2, // 設備工程師群組 InventoryGroup = 3, // 庫房工程師群組 ReportGroup = 4, // 報表使用群組 ERFDispositionGroup = 5, // 異常處理群組 ERFMailccGroup = 6 // 附件收件人群組 } private static string InXml, OutXml, strIdentity, strParameter, XmlData, XmlSchema; #region Invoke /// /// 叫用Web Service, 並回傳Response XML /// /// 要呼叫哪一個WebService的方法, ex: wsWIP.LoadLotBasis /// InXml /// 是否客製的WebService /// /// /// 2019/08/22 OwenLiu, Mantis:0061402, 修正WS加上CI/CO執行時間紀錄 運作邏輯後AutoRun Servive呼叫WS失敗的問題 /// public static string InvokeSrv(string Method, string InXml, bool Customize = false, int TimeOut = defInteger, bool LogOn = false) { object result; try { using (var ws = new iMESCore.Base.Invoke.wsInvoke.wsInvoke()) { ws.Url = modWIN.LocalizeWebService(ws.Url.ToString(), Customize); ws.EnableDecompression = true; if (TimeOut != defInteger) { ws.Timeout = TimeOut; } result = ws.invokeSrv(Method, new object[] { InXml, LogOn }); } } catch (Exception ex) { throw; } return Conversions.ToString(result); } /// /// 叫用Web Service, 回傳Response XML /// /// 要呼叫哪一個WebService的方法, ex: wsWIP.LoadLotBasis /// InXml /// 用來取回byte資料或傳入byte資料 /// 是否客製的WebService /// /// 2019/08/22 OwenLiu, Mantis:0061402, 修正WS加上CI/CO執行時間紀錄 運作邏輯後AutoRun Servive呼叫WS失敗的問題 /// public static string InvokeSrv(string Method, string InXml, byte[] buffer, bool Customize = false, int TimeOut = defInteger, bool LogOn = false) { object result; try { using (var ws = new iMESCore.Base.Invoke.wsInvoke.wsInvoke()) { ws.Url = modWIN.LocalizeWebService(ws.Url.ToString(), Customize); ws.EnableDecompression = true; if (TimeOut != defInteger) { ws.Timeout = TimeOut; } result = ws.invokeSrv(Method, new object[] { InXml, buffer, LogOn }); } } catch (Exception ex) { throw; } return Conversions.ToString(result); } /// /// 叫用Web Service, 並回傳Response XML /// /// 要呼叫哪一個WebService的方法, ex: wsWIP.LoadLotBasis /// InXml /// 接收結果的DataSet /// 是否客製的WebService /// public static string InvokeSrv(string Method, string InXml, ref DataSet pDataSet, bool Customize = false) { object result; try { using (var ws = new iMESCore.Base.Invoke.wsInvoke.wsInvoke()) { ws.Url = modWIN.LocalizeWebService(ws.Url.ToString(), Customize); ws.EnableDecompression = true; result = ws.invokeSrv_DataSet(Method, InXml, ref pDataSet); } } catch (Exception ex) { throw; } return Conversions.ToString(result); } public static string InvokeSrv_GuardServer(bool Customize = false) { object result; try { using (var ws = new iMESCore.Base.Invoke.wsInvoke.wsInvoke()) { ws.Url = modWIN.LocalizeWebService(ws.Url.ToString(), Customize); ws.EnableDecompression = true; result = ws.Invoke_GuardServer_Process(); } } catch (Exception ex) { throw; } return Conversions.ToString(result); } #endregion /// /// EAI 檢核編碼(MD5) /// /// /// public static string GetRequestKey(string input) { const string ID = "28682266"; // 鼎新統編 string key = ""; var md5Hasher = MD5.Create(); // 建立MD5物件 try { input += ID; // 將input轉換成MD5,並且以Bytes傳回,由於ComputeHash只接受Bytes型別參數,所以要先轉型別為Bytes byte[] data = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(input)); // 建立StringBuilder物件 var sb = new StringBuilder(); // 將Bytes轉型別為String,並且以16進位存放 for (int i = 0, loopTo = data.Length - 1; i <= loopTo; i++) sb.Append(data[i].ToString("x2")); key = sb.ToString(); } catch (Exception ex) { throw; } finally { md5Hasher = null; } return key; } /// /// 紀錄Transaction /// /// /// /// /// /// /// /// /// public static bool addTransactionLog(string InXml, string OutXml, string TransactionID, string ModuleID, string FunctionID, string ComputerName, string CurUserNo, string SendTime, string Result, string KeyValue, string ExceptionFun, string strException = null) { bool addTransactionLogRet = default(bool); try { using (var wsERP = new iMESCore.Base.Invoke.wsMES.wsMES()) { wsERP.Url = modWIN.LocalizeWebService_ERP(wsERP.Url.ToString()); wsERP.EnableDecompression = true; if (wsERP.addTransactionLog(InXml, OutXml, TransactionID, ModuleID, FunctionID, ComputerName, CurUserNo, SendTime, Result, KeyValue, ExceptionFun, ref strException) == true) { addTransactionLogRet = true; } else { addTransactionLogRet = false; } } } catch (Exception ex) { addTransactionLogRet = false; } return addTransactionLogRet; } /// /// 紀錄Transaction /// public static bool addTransactionLog_ErrorCode(string InXml, string OutXml, string TransactionID, string ModuleID, string FunctionID, string ComputerName, string CurUserNo, string SendTime, string Result, string KeyValue, string ExceptionFun, string strException = null, string ErrorCode = "0000-999999", string LogClass = null) { bool addTransactionLog_ErrorCodeRet = default(bool); try { using (var wsERP = new iMESCore.Base.Invoke.wsMES.wsMES()) { wsERP.Url = modWIN.LocalizeWebService_ERP(wsERP.Url.ToString()); wsERP.EnableDecompression = true; if (wsERP.addTransactionLog_ErrorCode(InXml, OutXml, TransactionID, ModuleID, FunctionID, ComputerName, CurUserNo, SendTime, Result, KeyValue, ExceptionFun, ref strException, ErrorCode, LogClass) == true) { addTransactionLog_ErrorCodeRet = true; } else { addTransactionLog_ErrorCodeRet = false; } } } catch (Exception ex) { addTransactionLog_ErrorCodeRet = false; } return addTransactionLog_ErrorCodeRet; } // =====Elvis ,0091128: [605][CP+FT] E10ICD整合問題_AutoRun主檔拋轉的ERP交易紀錄exception時紀錄不正確 #region --- Combine (Exception, Message) --- public static bool ChgTranslateException(ref List Exception, ref string strExceptionSysmsg, ref string strExceptionMesmsg, ref string strExceptionStack) { bool ChgTranslateExceptionRet = default(bool); try { foreach (ArrayList al in Exception) { // If strExceptionSysmsg <> String.Empty Then strExceptionSysmsg += Chr(10) if (string.IsNullOrEmpty(Conversions.ToString(al[1])) == false) strExceptionSysmsg += al[1].ToString(); // If String.IsNullOrEmpty(strExceptionMesmsg) = False Then strExceptionMesmsg += Chr(10) if (string.IsNullOrEmpty(Conversions.ToString(al[2])) == false) { // 翻譯錯誤訊息 string strErrName_Rep = ""; string ErrorName = al[2].ToString(); if (Strings.InStr(ErrorName, "[%", CompareMethod.Text) > 0) { string strKey, strKeyValue; int intStart, j, k, l; intStart = 1; j = 1; while (j != 0) { j = Strings.InStr(intStart, ErrorName, "[%", CompareMethod.Text); if (j == 0) { strErrName_Rep += Strings.Mid(ErrorName, intStart); } else { k = Strings.InStr(j + 2, ErrorName, "%]", CompareMethod.Text); if (k == 0) { // 找不到對應的結束字元. strErrName_Rep += Strings.Mid(ErrorName, intStart); j = 0; } else { // 檢查是否有不對稱的情況. l = Strings.InStr(j + 2, ErrorName, "[%", CompareMethod.Text); if (l == 0 || l > k) { strErrName_Rep += Strings.Mid(ErrorName, intStart, j - intStart); strKey = Strings.Mid(ErrorName, j + 2, k - j - 2); // 將Key執行語系轉換 try { strKeyValue = ""; } // strKeyValue = Resources.Resource.ResourceManager.GetString(strKey) catch (Exception ex) { strKeyValue = strKey; } if (string.IsNullOrEmpty(strKeyValue)) { strErrName_Rep += strKey; } else { strErrName_Rep += strKeyValue; } // & "(" & strKey & ")" // 下次截取字串的起始位置 intStart = k + 2; } else { // 不對稱,找到最內層的[%%] int m; // 在前面的條件下,一定找得到. m = Strings.InStrRev(ErrorName, "[%", k, CompareMethod.Text); // 擷出不轉換的字串. strErrName_Rep += Strings.Mid(ErrorName, intStart, m - intStart); strKey = Strings.Mid(ErrorName, m + 2, k - m - 2); // 將Key執行語系轉換 try { strKeyValue = ""; } // strKeyValue = Resources.Resource.ResourceManager.GetString(strKey) catch (Exception ex) { strKeyValue = strKey; } if (string.IsNullOrEmpty(strKeyValue)) { strErrName_Rep += strKey; } else { strErrName_Rep += strKeyValue; } // & "(" & strKey & ")" // 下次截取字串的起始位置 intStart = k + 2; } } } } } // strExceptionMesmsg += Chr(9) & Chr(9) & Chr(9) & Resources.Resource.ResourceManager.GetString(al.Item(2).ToString) & "(" & al.Item(2).ToString & ")" strExceptionMesmsg += strErrName_Rep; } // If strExceptionStack <> String.Empty Then strExceptionStack += Chr(10) if (string.IsNullOrEmpty(Conversions.ToString(al[3])) == false) strExceptionStack += al[3].ToString(); } ChgTranslateExceptionRet = true; } catch (Exception e1) { throw; ChgTranslateExceptionRet = false; } return ChgTranslateExceptionRet; } public static string CombineXMLResponse(string Identity, string ReturnValue = null, List Exception = null, string Result = null, List Message = null) { string CombineXMLResponseRet = default(string); try { // CombineXMLResponseRet = ""; // if (string.IsNullOrEmpty(Identity)) { CombineXMLResponseRet += ""; } else { CombineXMLResponseRet += ""; CombineXMLResponseRet += Identity; CombineXMLResponseRet += ""; } // if (string.IsNullOrEmpty(ReturnValue)) { CombineXMLResponseRet += ""; } else { CombineXMLResponseRet += ""; CombineXMLResponseRet += ReturnValue; CombineXMLResponseRet += ""; } // if (string.IsNullOrEmpty(Result)) { CombineXMLResponseRet += ""; } else { CombineXMLResponseRet += "" + Result + ""; } // string strExceptionSysmsg = string.Empty; string strExceptionMesmsg = string.Empty; string strExceptionStack = string.Empty; if (Exception.Count == 0) { CombineXMLResponseRet += ""; } else { // 2016-12-01, Joe, Exception轉語系 ChgTranslateException(ref Exception, ref strExceptionSysmsg, ref strExceptionMesmsg, ref strExceptionStack); CombineXMLResponseRet += ""; CombineXMLResponseRet += ""; if (string.IsNullOrEmpty(strExceptionSysmsg) == true) { CombineXMLResponseRet += ""; } else { CombineXMLResponseRet += "" + strExceptionSysmsg + '\n' + "" + '\n'; } if (string.IsNullOrEmpty(strExceptionMesmsg) == true) { CombineXMLResponseRet += "" + strExceptionMesmsg + "" + '\n'; } else { CombineXMLResponseRet += "" + strExceptionMesmsg + "" + '\n'; } if (string.IsNullOrEmpty(strExceptionStack)) { CombineXMLResponseRet += ""; } else { // CombineXMLResponse += Chr(9) & Chr(9) & "" & Chr(10) & strExceptionStack & Chr(10) & Chr(9) & Chr(9) & "" & Chr(10) CombineXMLResponseRet += ""; } CombineXMLResponseRet += '\t' + "" + '\n'; } // string strMmsg = string.Empty; if (Message.Count == 0) { CombineXMLResponseRet += '\t' + "" + '\n'; } else { CombineXMLResponseRet += '\t' + "" + '\n'; // 2016-12-01, Joe, Message轉語系 // Call ChgTranslateMessage(Message, strMmsg) CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + strMmsg + "" + '\n'; CombineXMLResponseRet += '\t' + "" + '\n'; } CombineXMLResponseRet += "" + '\n'; } catch (Exception e1) { // 發生錯誤時丟回本身的Function Name及系統錯誤訊息 // Throw 'New Exception("modWS.CombineXMLResponse: " & e1.Message) CombineXMLResponseRet = "" + '\n'; CombineXMLResponseRet += '\t' + "" + '\n'; CombineXMLResponseRet += '\t' + "" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + '\t' + e1.Message + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + '\t' + "CombineXMLResponse;Fail" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += e1.StackTrace + '\n'; CombineXMLResponseRet += Conversions.ToString('\t') + '\t' + "" + '\n'; CombineXMLResponseRet += '\t' + "" + '\n'; CombineXMLResponseRet += '\t' + "" + '\n'; CombineXMLResponseRet += ""; } return CombineXMLResponseRet; } public static bool combineException(ref List arrException, string code = null, string sysmsg = null, string mesmsg = null, string stack = null) { bool result = false; try { var al = new ArrayList(); al.Add(code); al.Add(sysmsg); al.Add(mesmsg); al.Add(stack); arrException.Add(al); result = true; } catch (Exception ex) { result = false; } return default(Boolean); } // Public Function combineMessage( // ByRef strMessage As List(Of ArrayList), // Optional ByVal mcode As String = Nothing, // Optional ByVal mtype As String = Nothing, // Optional ByVal mmsg As String = Nothing // ) As Boolean // Dim result As Boolean = False // Try // Dim al As New ArrayList // al.Add(mcode) // al.Add(mtype) // al.Add(mmsg) // strMessage.Add(al) // result = True // Catch ex As Exception // result = False // End Try // End Function #endregion // ===== // 發Mail功能 非群組與群組發送 public static string SendMultiEmail(ref string FileName, ref string EmailSubject, string EmailBody = defString, string GroupNo = defString, byte[] AttachFile = null, GroupType GroupType = GroupType.UserGroup) { string SendMultiEmailRet = default(string); // GroupType // 0:User Group (使用者群組) // 1:Issue Group (簽核群組) // 2:Equipment Group(設備工程師群組) // 3:Inventory Group(庫房工程師群組) // 4:Report Group(報表使用群組) // 5:ERF Disposition Group(異常處理群組) // 6:ERF Mail ccGroup(附件收件人群組) try { strIdentity = CombineXMLIdentity(modWIN.gComputerName, "AUTORUN", DateTime.Now.ToString()); strParameter = CombineXMLParameter("groupno", "GroupNo", "String", CInput(GroupNo), ""); strParameter = strParameter + CombineXMLParameter("emailsubject", "EmailSubject", "String", EmailSubject, ""); strParameter = strParameter + CombineXMLParameter("emailbody", "EmailBody", "String", EmailBody, ""); strParameter = strParameter + CombineXMLParameter("grouptype", "GroupType", "Integer", ((int)GroupType).ToString(), ""); strParameter = strParameter + CombineXMLParameter("attachfilename", "AttachFileName", "String", FileName, ""); var XmlDoc = new XmlDocument(); InXml = CombineXMLRequest(strIdentity, strParameter); // OutXml = wsWIP.SendEmailAndAttachFileToGroup(InXml, AttachFile) OutXml = InvokeSrv("wsWIP.SendEmailAndAttachFileToGroup", InXml, AttachFile); XmlDoc.LoadXml(OutXml); if (chkExecutionSuccess(XmlDoc)) // 找出Exception訊並顯示出來 { SendMultiEmailRet = "success"; } else { SendMultiEmailRet = "fail"; } XmlDoc = null; } catch (Exception ex) { SendMultiEmailRet = "fail;" + ex.Message; } return SendMultiEmailRet; } #region --- 數值查核 --- public static bool funChkNumericIsValid(string pSourceText, bool AllowFloat = true, bool AllowContainsDot = true, bool AllowZeroValue = true, bool AllowMinus = true) { bool blnExecResult = false; decimal decInputValue = 0m; try { if (!Information.IsNumeric(pSourceText)) { blnExecResult = false; return blnExecResult; } decInputValue = Convert.ToDecimal(pSourceText); if (!AllowMinus && decInputValue < 0m) { blnExecResult = false; return blnExecResult; } if (!AllowZeroValue && decInputValue == 0m) { blnExecResult = false; return blnExecResult; } if (!AllowFloat) { if (decInputValue % 1m > 0m) { blnExecResult = false; return blnExecResult; } } if (!AllowContainsDot && !pSourceText.IndexOf(".").Equals(-1)) { blnExecResult = false; return blnExecResult; } blnExecResult = true; } catch (Exception ex) { throw; } return blnExecResult; } #endregion public static byte[] funExcelToByte(DataSet dsResult, String ExcelMode, String strLanguageMode, String strResourceDir) { var memStream = new MemoryStream(); IWorkbook workbook = null; int title = 0; byte[] membyte; try { // 匯出Excel再轉Stream if (ExcelMode == "XLSX") { workbook = new XSSFWorkbook(); } else { workbook = new HSSFWorkbook(); } // Add a new worksheet ISheet worksheet = workbook.CreateSheet("Sheet1"); // Add the TSSAVE data table to the worksheet IRow headerRow = worksheet.CreateRow(0); for (int i = 0; i <= dsResult.Tables[0].Columns.Count - 1; i++) { string strLanguage = dsResult.Tables[0].Columns[i].ToString(); strLanguage = TranslateMsg("[%" + strLanguage + "%]", strLanguageMode, strResourceDir); //語系翻譯 headerRow.CreateCell(i).SetCellValue(strLanguage); } for (int i = 0; i <= dsResult.Tables[0].Rows.Count - 1; i++) { IRow dataRow = worksheet.CreateRow(i + 1); for (int j = 0; j <= dsResult.Tables[0].Columns.Count - 1; j++) { var objdsResultType = dsResult.Tables[0].Rows[i][j].GetType(); dataRow.CreateCell(j); if (!Convert.IsDBNull(dsResult.Tables[0].Rows[i][j])) { dataRow.CreateCell(j).SetCellValue(dsResult.Tables[0].Rows[i][j].ToString()); } else if (objdsResultType.Name == "DateTime") { DateTime datedsTemp = DateTime.Parse(dsResult.Tables[0].Rows[i][j].ToString()); dataRow.CreateCell(j).SetCellValue(datedsTemp); } else if (objdsResultType.Name == "Decimal") { decimal amount; amount = Convert.ToDecimal(dsResult.Tables[0].Rows[i][j].ToString()); dataRow.CreateCell(j).SetCellValue((double)amount); } else { dataRow.CreateCell(j).SetCellValue(dsResult.Tables[0].Rows[i][j].ToString()); } //.抓取值 IRow SelectRow = worksheet.GetRow(i); ICell SelectCell = SelectRow.GetCell(j); //Style處理 if (i == 0) title = 1; else title = 0; funCellStyleClone(workbook, SelectCell, title, ExcelMode); } } //Columns 寬度 for (int i = 0; i <= dsResult.Tables[0].Columns.Count - 1; i++) { worksheet.AutoSizeColumn(i); } ////debug 用 //var fileStream = File.Create($"{DateTime.Now.ToString("HHmmss")}.xlsx"); //FileStream fs = new FileStream(@"c:\test.xlsx", FileMode.Create); //workbook.Write(fs); //fs.Close(); //// workbook.Write(memStream); membyte = memStream.ToArray(); return membyte; } catch (Exception ex) { throw; } finally { workbook?.Close(); memStream.Close(); memStream.Dispose(); } } public static void funCellStyleClone(IWorkbook Workbook, ICell SourceCell, int title, String ExcelMode) { try { ICellStyle CellStyle = Workbook.CreateCellStyle(); IFont CellFont = Workbook.CreateFont(); if (title == 1) { CellStyle.BorderLeft = BorderStyle.None; CellStyle.BorderRight = BorderStyle.None; CellStyle.BorderTop = BorderStyle.None; if (ExcelMode == "XLSX") { XSSFColor xssfColor = new XSSFColor(); byte[] colorRgb = { (byte)192, (byte)192, (byte)255 }; xssfColor.SetRgb(colorRgb); ((XSSFCellStyle)CellStyle).FillForegroundColorColor = xssfColor; ((XSSFCellStyle)CellStyle).FillPattern = FillPattern.SolidForeground; } else { CellStyle.FillForegroundColor = (((HSSFWorkbook)Workbook).GetCustomPalette().FindSimilarColor((byte)192, (byte)192, (byte)255)).Indexed; CellStyle.FillBackgroundColor = (((HSSFWorkbook)Workbook).GetCustomPalette().FindSimilarColor((byte)192, (byte)192, (byte)255)).Indexed; } CellStyle.FillPattern = FillPattern.SolidForeground; CellStyle.BorderBottom = BorderStyle.None; CellStyle.Alignment = HorizontalAlignment.Center; SourceCell.CellStyle = CellStyle; } else { CellStyle.BorderLeft = BorderStyle.Thin; CellStyle.BorderRight = BorderStyle.Thin; CellStyle.BorderTop = BorderStyle.Thin; CellStyle.BorderBottom = BorderStyle.Thin; if (ExcelMode == "XLSX") { XSSFColor xssfColor = new XSSFColor(); byte[] colorRgb = { (byte)192, (byte)192, (byte)255 }; xssfColor.SetRgb(colorRgb); ((XSSFCellStyle)CellStyle).SetTopBorderColor(xssfColor); ((XSSFCellStyle)CellStyle).SetRightBorderColor(xssfColor); ((XSSFCellStyle)CellStyle).SetLeftBorderColor(xssfColor); ((XSSFCellStyle)CellStyle).SetBottomBorderColor(xssfColor); } else { CellStyle.LeftBorderColor = (((HSSFWorkbook)Workbook).GetCustomPalette().FindSimilarColor((byte)192, (byte)192, (byte)255)).Indexed; CellStyle.RightBorderColor = (((HSSFWorkbook)Workbook).GetCustomPalette().FindSimilarColor((byte)192, (byte)192, (byte)255)).Indexed; CellStyle.TopBorderColor = (((HSSFWorkbook)Workbook).GetCustomPalette().FindSimilarColor((byte)192, (byte)192, (byte)255)).Indexed; CellStyle.BottomBorderColor = (((HSSFWorkbook)Workbook).GetCustomPalette().FindSimilarColor((byte)192, (byte)192, (byte)255)).Indexed; } CellStyle.FillPattern = FillPattern.SolidForeground; CellStyle.Alignment = HorizontalAlignment.Left; SourceCell.CellStyle = CellStyle; } // 文字 CellFont.FontHeightInPoints = 9; //CellFont.Boldweight = StyleFon.Boldweight; //CellFont.Charset = StyleFon.Charset; //CellFont.Color = StyleFon.Color; //CellFont.FontHeight = 9; //CellFont.FontHeightInPoints = StyleFon.FontHeightInPoints; //CellFont.FontName = StyleFon.FontName; //CellFont.IsItalic = StyleFon.IsItalic; //CellFont.IsStrikeout = StyleFon.IsStrikeout; //CellFont.Underline = StyleFon.Underline; CellStyle.SetFont(CellFont); } catch (Exception ex) { throw; } } } }