private void CreateDataSheet(ExcelHelp xls, DataTableInfo tableInfo, bool isTarget) { DatabaseAcsesser dba = new DatabaseAcsesser(); DatabaseAcsesser.DbConnections connType = isTarget ? DatabaseAcsesser.DbConnections.TargetDbConnection : DatabaseAcsesser.DbConnections.SourceDbConnection; TableLayoutInfo info = dba.GetTableLayout(connType, tableInfo.TableName); Excel.Worksheet templateSheet = xls.WorkBook.Sheets["Template"]; Excel.Worksheet sheet = xls.CreateSheet(tableInfo.SheetName, templateSheet); int colIndex = 0; xls.WriteValue(sheet, 1, 2, info.TableName); foreach (ColumnInfo column in info.Columns) { colIndex++; xls.WriteValue(sheet, STRAT_ROW, colIndex, column.ColumnName); if (!string.IsNullOrEmpty(column.DisplayName)) { string comment = column.DisplayName + "\n" + column.GetSqlType(); sheet.Range[xls.GetColumnName(colIndex, STRAT_ROW)].AddComment(comment); } if (column.IsPrimaryKey) { Excel.Range cell = sheet.Range[xls.GetColumnName(colIndex, STRAT_ROW)]; cell.Font.Color = Excel.XlRgbColor.rgbRed; } } xls.AddListObject(sheet, STRAT_ROW, STRAT_ROW + 1, colIndex, tableInfo.TableName); SetColumnFormat(info, sheet); sheet.Columns.AutoFit(); sheet.Tab.Color = isTarget ? Excel.XlRgbColor.rgbBlue : Excel.XlRgbColor.rgbRed; }
private TableLayoutInfo GetTableLayoutInfo(string tableName, bool isTarget) { DatabaseAcsesser dba = new DatabaseAcsesser(); DatabaseAcsesser.DbConnections connType = isTarget ? DatabaseAcsesser.DbConnections.TargetDbConnection : DatabaseAcsesser.DbConnections.SourceDbConnection; TableLayoutInfo info = dba.GetTableLayout(connType, tableName); return(info); }