public void OnConvertSheetStart(string sheetName, ISheetReader reader) { int tsetRow = reader.FindLineByFirst("TEST", 10); if (tsetRow != -1) { _tempExcelData.NewSheet(sheetName, reader.GetLineCell(tsetRow), reader.GetLineCell(3)); } }
private void LoadSetting(ISheetReader settingSheet) { int line = 1; while (true) { line++; var lineData = settingSheet.GetLineCell(line); if (lineData == null) { break; } var type = GetLineType(lineData); if (type == LineType.End_Before) { break; } if (type == LineType.No) { continue; } SetSetting(lineData[1], lineData[2]); if (type == LineType.End) { break; } } }
private void LoadSheet(ISheetReader sheetReader) { int line = StartLine; while (true) { var lineData = sheetReader.GetLineCell(line); line++; if (lineData == null) { break; } var type = GetLineType(lineData); if (type == LineType.End_Before) { break; } if (type == LineType.No) { continue; } if (keys.Contains(lineData[Main_Key_Index])) { Log.e($"{_excelReader.ExcelName}.{sheetReader.GetSheetName()} 主键重复 {lineData[0]}", true); return; } keys.Add(lineData[Main_Key_Index]); OnLoadLine(lineData); if (type == LineType.End) { break; } } }
public ConvertExceptionInfo ConvertSheet(ISheetReader sheetReader) { _sheetName = sheetReader.GetSheetName(); // 1. 分页第一行第一列是否有值 var firstValue = sheetReader.GetCell(1, 1); if (string.IsNullOrEmpty(firstValue.ToString())) { SystemUtil.Wran(string.Format("SheetName [{0}] 不导出!", sheetReader.GetSheetName())); return(null); } // 2. 检查客户端字段以及类型定义 var error = DetectionFourLine(sheetReader.GetLineCell(1), sheetReader.GetLineCell(2), sheetReader.GetLineCell(3)); if (error != null) { SystemUtil.Print(error); if (error.InfoType == ExceptionInfoType.Warn) { return(null); } } // Event EventHandel?.OnConvertSheetStart(_sheetName, sheetReader); int currentRow = START_ROW; // Test if (sheetReader.HasFirst("TEST")) { currentRow++; } bool isBreak = false; string[] lineData = null; while (true) { if (isBreak) { // 结束 break; } // 执行行命令 var lineCmd = ParseCmd(sheetReader.GetCell(currentRow, sheetReader.StartCol)); if (lineCmd == LineCmd.Ignore) { ++currentRow; continue; } else if (lineCmd == LineCmd.EndBefore) { break; } else if (lineCmd == LineCmd.End) { isBreak = true; } // 获取行数据 lineData = sheetReader.GetLineCell(currentRow); if (lineData == null) { isBreak = true; if (currentRow == START_ROW) { SystemUtil.Wran(ContentInfo("分页为空,不导出!")); } else { SystemUtil.Wran(ContentInfo(string.Format("({0})行数据为空,自动跳出!", currentRow))); } continue; } // 导出为lua ParseLine(lineData, currentRow); EventHandel?.OnConvertSheetLine(currentRow, lineData); ++_convertCount; ++currentRow; } EventHandel?.OnConvertSheetEnd(_sheetName); SystemUtil.Log(ContentInfo("Finish!"), System.ConsoleColor.Green); return(null); }
private void ResetSettingDatas(ISheetReader sheetReader) { SettingDatas.Clear(); SettingDatas.Add((SettingType)System.Enum.Parse(typeof(SettingType), "TYPE"), sheetReader.GetLineCell(TypeLine)); SettingDatas.Add((SettingType)System.Enum.Parse(typeof(SettingType), "FIELD"), sheetReader.GetLineCell(FieldLine)); }