private void AddCategoriesSections(IList <CategoryDto> categories, IList <SubcategoryDto> subcategories) { foreach (var category in categories) { AddCategorySection(category, subcategories.Where(x => x.CategoryId == category.Id)); if (!category.Equals(categories.Last())) { _googleSheetService.AddEmptyRow(); } } }
private void AddCategoriesTable(IList <CategoryDto> categories, IList <SubcategoryDto> subcategories) { foreach (var category in categories) { AddCategoryRow(category); } var cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Sum:" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), Borders = GoogleSheetService.GetTopMediumBorder(), HorizontalAlignment = "RIGHT", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"=SUM({GoogleSheetService.GetCellAddress(1, _googleSheetService.CurrentRow - categories.Count)}:{GoogleSheetService.GetCellAddress(1, _googleSheetService.CurrentRow - 1)})" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), Borders = GoogleSheetService.GetTopMediumBorder(), } }); _googleSheetService.AddRow(cells); _googleSheetService.AddEmptyRow(); _googleSheetService.AddEmptyRow(); }
private void AddSpendingHeader() { var cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Spending" }, UserEnteredFormat = new CellFormat() { BackgroundColor = GetSheetsColor(), TextFormat = new TextFormat() { FontSize = 18, Bold = true, FontFamily = "Verdana", }, VerticalAlignment = "MIDDLE", HorizontalAlignment = "CENTER" } }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Budget Plan" }, UserEnteredFormat = SubHeaderFormat(), }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Planned income" } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = "=B13" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting() } }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Planned spending" } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = "=B14" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "To allocate" } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = "=B3-B4" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); _googleSheetService.AddRow(cells); _googleSheetService.AddEmptyRow(); //Budget Realisation cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Budget Realization" }, UserEnteredFormat = SubHeaderFormat(), }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Actual income" } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = "=C13" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Actual spending" } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = "=C14" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Still available" } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = "=B8-B9" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); _googleSheetService.AddRow(cells); _googleSheetService.AddEmptyRow(); //Header table cells = new List <CellData>(); cells.Add(new CellData()); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Planned" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), HorizontalAlignment = "RIGHT", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Actual" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), HorizontalAlignment = "RIGHT", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Difference" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), HorizontalAlignment = "RIGHT", } }); _googleSheetService.AddRow(cells); //Income sum: cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Income sum:" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), HorizontalAlignment = "RIGHT" } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"={GoogleSheetService.GetCellAddress(1, _googleSheetService.CurrentRow + 5)}" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"={GoogleSheetService.GetCellAddress(2, _googleSheetService.CurrentRow + 5)}" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"={GoogleSheetService.GetCellAddress(3, _googleSheetService.CurrentRow + 5)}" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" } } }); _googleSheetService.AddRow(cells); //Spending sum: cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Spending sum:" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), HorizontalAlignment = "RIGHT" } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { NumberValue = 0 }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { NumberValue = 0 }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = "=C14-B14" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" } } }); cells.ForEach(x => _subcategoriesRows.Add(x)); _googleSheetService.AddRow(cells); _googleSheetService.AddEmptyRow(); _googleSheetService.MergeRange(new GridRange() { StartRowIndex = 0, EndRowIndex = 1, StartColumnIndex = 0, EndColumnIndex = 5 }); }