public Table(TableTitle tableName, IAccount account) { Id = new BaseEntityId(Guid.NewGuid()); Name = tableName; CreateDate = DateTime.Now; AccountId = account.Id; State = TableState.Actual; Tasks = new TableTaskCollection(); }
/// <summary>读取excel /// 默认第一行为标头 /// </summary> /// <param name="strFileName">excel文档路径</param> /// <returns></returns> public static GZDataTable Import(string strFileName) { string TableTitle; string DateString; DataTable dt = new DataTable(); HSSFWorkbook hssfworkbook; using (FileStream file = new FileStream(strFileName, FileMode.Open, FileAccess.Read)) { hssfworkbook = new HSSFWorkbook(file); } ISheet sheet = hssfworkbook.GetSheetAt(0); System.Collections.IEnumerator rows = sheet.GetRowEnumerator(); IRow titleRow = sheet.GetRow(sheet.FirstRowNum); TableTitle = titleRow.Cells[0].ToString().ToString().Trim(); TableTitle = TableTitle.Replace("\0", ""); IRow DateRow = sheet.GetRow(sheet.FirstRowNum + 1); DateString = DateRow.Cells[0].ToString().ToString().Trim().Replace("\0", ""); IRow headerRow = sheet.GetRow(IndexOfTitleRow); int cellCount = headerRow.LastCellNum; for (int j = 0; j < cellCount; j++) { ICell cell = headerRow.GetCell(j); dt.Columns.Add(cell.ToString()); } for (int i = (sheet.FirstRowNum + IndexOfTitleRow + 1); i <= sheet.LastRowNum; i++) { IRow row = sheet.GetRow(i); DataRow dataRow = dt.NewRow(); bool flag = true; for (int j = row.FirstCellNum; j < cellCount; j++) { if (row.GetCell(j) != null) { dataRow[j] = row.GetCell(j).ToString(); if (dataRow[j].ToString().IndexOf("合计") >= 0) { flag = false; } } } if (flag) { dt.Rows.Add(dataRow); } } GZDataTable result = new GZDataTable(DateString, TableTitle, dt); return(result); }
/// <summary> /// Sets the table caption. /// </summary> /// <param name="table">The table.</param> /// <param name="caption">The caption.</param> /// <returns>The same instance so that multiple calls can be chained.</returns> public static Table Caption(this Table table, TableTitle caption) { if (table is null) { throw new ArgumentNullException(nameof(table)); } table.Caption = caption; return(table); }
/// <summary> /// Sets the table title. /// </summary> /// <param name="table">The table.</param> /// <param name="title">The table title.</param> /// <returns>The same instance so that multiple calls can be chained.</returns> public static Table Title(this Table table, TableTitle title) { if (table is null) { throw new ArgumentNullException(nameof(table)); } table.Title = title; return(table); }
static async Task Main(string[] args) { string name, surname; int birthday; List <Person> personsList = new List <Person> (); do { Console.WriteLine("1- Para agregar persona\n2- Para mostrar información"); var option = int.Parse(Console.ReadLine()); switch (option) { case 1: name = AnsiConsole.Ask <string> ("Cual es tu [blue]nombre[/]?"); surname = AnsiConsole.Ask <string> ("Cual es tu [blue]apellido[/]?"); birthday = AnsiConsole.Ask <int> ("Cual es tu [green]año de nacimiento[/]?"); Person persona = new Person(name, surname, birthday); personsList.Add(persona); AnsiConsole.Status() .Start("Guardando...", ctx => { Thread.Sleep(1000); // Update the status and spinner ctx.Status("Finalizado"); ctx.Spinner(Spinner.Known.Star); ctx.SpinnerStyle(Style.Parse("green")); Thread.Sleep(1000); }); Console.Clear(); break; case 2: var saveTable = AnsiConsole.Confirm("Guardar tabla?"); AnsiConsole.Record(); Table table = new Table(); table.AddColumn("Nombre"); table.AddColumn("Apellido"); table.AddColumn("Edad"); table.AddColumn("Pais"); table.AddColumn("Ciudad"); table.AddColumn("Idioma"); table.AddColumn("Cordenadas"); foreach (var item in personsList) { table.AddRow(item.Name, item.Surname, item.Birthday.ToString(), item.Country, item.City, item.Language, item.Cordinates); } var title = new TableTitle("Empleado", Style.WithDecoration(Decoration.Bold)); table.Title = title; table.Border(TableBorder.Rounded); table.BorderColor <Table> (Color.Blue); AnsiConsole.Render(table); if (saveTable) { string html = AnsiConsole.ExportHtml(); Directory.CreateDirectory("../Employes"); File.WriteAllText("../Employes/index.html", html); Console.ForegroundColor = Color.Green; Console.WriteLine("Guardado Exitosamente"); Console.ForegroundColor = Color.White; } break; default: break; } } while (true); }
public ITable NewTable(TableTitle tableName, IAccount account) => new Entities.Table(tableName, account);
public CreateTableInput(TableTitle tableName, BaseEntityId accountId) { TableName = tableName; AccountId = accountId; }
public ChangeTableTitleInput(BaseEntityId accountId, BaseEntityId tableId, TableTitle title) { AccountId = accountId; TableId = tableId; Title = title; }