private void AddChartsHeader() { var cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Charts" }, UserEnteredFormat = new CellFormat() { BackgroundColor = GetSheetsColor(), TextFormat = new TextFormat() { FontSize = 18, Bold = true, }, VerticalAlignment = "MIDDLE", HorizontalAlignment = "CENTER" } }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Category" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetAllBorders(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Spent" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetAllBorders(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), HorizontalAlignment = "RIGHT", } }); _googleSheetService.AddRow(cells); _googleSheetService.MergeRange(new GridRange() { StartRowIndex = 0, EndRowIndex = 1, StartColumnIndex = 0, EndColumnIndex = 7 }); }
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 AddCategoryHeader(string categoryName, int subcategoriesCount) { var cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = categoryName }, UserEnteredFormat = SubHeaderFormat(), }); _budget.Categories.FirstOrDefault(x => x.Name.ToLower() == categoryName.ToLower()).RowIndex = _googleSheetService.CurrentRow; _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Name" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetTopBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), WrapStrategy = "WRAP", VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Planned spending" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetTopBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), WrapStrategy = "WRAP", HorizontalAlignment = "RIGHT", VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Actual spending" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetTopBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), WrapStrategy = "WRAP", HorizontalAlignment = "RIGHT", VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Difference" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetTopBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), WrapStrategy = "WRAP", HorizontalAlignment = "RIGHT", VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Realization" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetTopBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), WrapStrategy = "WRAP", HorizontalAlignment = "CENTER", VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData()); for (int i = 0; i < DateTime.DaysInMonth(_budget.Month.Year, _budget.Month.Month); i++) { cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"=SUM({GoogleSheetService.GetCellAddress(6 + i, _googleSheetService.CurrentRow + 2)}:{GoogleSheetService.GetCellAddress(6 + i, _googleSheetService.CurrentRow + 2 + subcategoriesCount - 1)})" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, Borders = GoogleSheetService.GetTopBorder(), TextFormat = GoogleSheetService.GetDefaultCellFormatting(), VerticalAlignment = "MIDDLE", } }); } _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Sum:" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetBottomBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"=SUM({GoogleSheetService.GetCellAddress(1, _googleSheetService.CurrentRow + 1)}:{GoogleSheetService.GetCellAddress(1, _googleSheetService.CurrentRow + subcategoriesCount)})" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, Borders = GoogleSheetService.GetBottomBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"=SUM({GoogleSheetService.GetCellAddress(2, _googleSheetService.CurrentRow + 1)}:{GoogleSheetService.GetCellAddress(2, _googleSheetService.CurrentRow + subcategoriesCount)})" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, Borders = GoogleSheetService.GetBottomBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"={GoogleSheetService.GetCellAddress(2, _googleSheetService.CurrentRow)}-{GoogleSheetService.GetCellAddress(1, _googleSheetService.CurrentRow)}" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, Borders = GoogleSheetService.GetBottomBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"=IFERROR({GoogleSheetService.GetCellAddress(2, _googleSheetService.CurrentRow)}/{GoogleSheetService.GetCellAddress(1, _googleSheetService.CurrentRow)}; \"-\")" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "PERCENT", Pattern = "0.00%" }, Borders = GoogleSheetService.GetBottomBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), HorizontalAlignment = "CENTER", VerticalAlignment = "MIDDLE", } }); cells.Add(new CellData()); DateTime columnDate = new DateTime(_budget.Month.Year, _budget.Month.Month, 1); for (int i = 0; i < DateTime.DaysInMonth(_budget.Month.Year, _budget.Month.Month); i++) { cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = $"{columnDate.ToString("yyyy-MM-dd")}" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetBottomBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), HorizontalAlignment = "CENTER", VerticalAlignment = "MIDDLE", } }); columnDate = columnDate.AddDays(1); } _googleSheetService.AddRow(cells); }
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 }); }
private void AddDashboardHeader() { var cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Dashboard" }, UserEnteredFormat = new CellFormat() { BackgroundColor = GetSheetsColor(), TextFormat = new TextFormat() { FontSize = 18, Bold = true, }, VerticalAlignment = "MIDDLE", HorizontalAlignment = "CENTER" } }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Subcategory" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetBottomMediumBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "BOTTOM", WrapStrategy = "WRAP", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Planned spending" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetBottomMediumBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "BOTTOM", HorizontalAlignment = "RIGHT", WrapStrategy = "WRAP", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Actual spending" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetBottomMediumBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "BOTTOM", HorizontalAlignment = "RIGHT", WrapStrategy = "WRAP", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Difference" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetBottomMediumBorder(), TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "BOTTOM", HorizontalAlignment = "RIGHT", WrapStrategy = "WRAP", } }); _googleSheetService.AddRow(cells); _googleSheetService.MergeRange(new GridRange() { StartRowIndex = 0, EndRowIndex = 1, StartColumnIndex = 0, EndColumnIndex = 4 }); }
private void AddSummarySection() { var cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Total sum:" }, UserEnteredFormat = new CellFormat() { Borders = GoogleSheetService.GetTopMediumBorder(), TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"=Spending!{GoogleSheetService.GetCellAddress(1, 13)}" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, Borders = GoogleSheetService.GetTopMediumBorder(), TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"=Spending!{GoogleSheetService.GetCellAddress(2, 13)}" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, Borders = GoogleSheetService.GetTopMediumBorder(), TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { FormulaValue = $"=Spending!{GoogleSheetService.GetCellAddress(3, 13)}" }, UserEnteredFormat = new CellFormat() { NumberFormat = new NumberFormat() { Type = "CURRENCY" }, Borders = GoogleSheetService.GetTopMediumBorder(), TextFormat = GoogleSheetService.GetDefaultCellFormatting(), } }); _googleSheetService.AddRow(cells); cells = new List <CellData>(); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Subcategory" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "TOP", Borders = GoogleSheetService.GetTopBorder(), WrapStrategy = "WRAP", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Planned spending" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "TOP", HorizontalAlignment = "RIGHT", Borders = GoogleSheetService.GetTopBorder(), WrapStrategy = "WRAP", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Actual spending" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "TOP", HorizontalAlignment = "RIGHT", Borders = GoogleSheetService.GetTopBorder(), WrapStrategy = "WRAP", } }); cells.Add(new CellData() { UserEnteredValue = new ExtendedValue() { StringValue = "Difference" }, UserEnteredFormat = new CellFormat() { TextFormat = GoogleSheetService.GetDefaultTableHeaderFormatting(), VerticalAlignment = "TOP", HorizontalAlignment = "RIGHT", Borders = GoogleSheetService.GetTopBorder(), WrapStrategy = "WRAP", } }); _googleSheetService.AddRow(cells); }