@using Radzen.Blazor.Spreadsheet
@using Radzen.Documents.Spreadsheet

<RadzenSpreadsheet Workbook=@workbook style="height: 600px" />

@code {
    Workbook workbook = new Workbook();

    protected override void OnInitialized()
    {
        var sheet = workbook.AddSheet("Links & Images", 30, 8);

        sheet.BeginUpdate();

        sheet.Columns[0] = 160;
        sheet.Columns[1] = 250;
        sheet.Columns[2] = 200;

        var sectionFormat = new Format { Bold = true, FontSize = 12, BackgroundColor = "#1565c0", Color = "#ffffff" };
        var headerFormat = new Format { Bold = true, BackgroundColor = "#e3f2fd", Color = "#005da1" };
        var noteFormat = new Format { Color = "#757575", Italic = true };

        // --- Hyperlinks Section ---
        sheet.MergedCells.Add(RangeRef.Parse("A1:C1"));
        sheet.Cells["A1"].Value = "Hyperlinks";
        sheet.Cells["A1"].Format = sectionFormat;
        sheet.Rows[0] = 28;

        sheet.Cells["A2"].Value = "Description"; sheet.Cells["A2"].Format = headerFormat;
        sheet.Cells["B2"].Value = "Link"; sheet.Cells["B2"].Format = headerFormat;

        // Web URL
        sheet.Cells["A3"].Value = "Website Link";
        sheet.Cells["B3"].Value = "Radzen Blazor Components";
        sheet.Cells["B3"].Hyperlink = new Hyperlink { Url = "https://blazor.radzen.com", Text = "Radzen Blazor Components" };
        sheet.Cells["B3"].Format = new Format { Color = "#1565c0", Underline = true };

        // GitHub
        sheet.Cells["A4"].Value = "GitHub Repository";
        sheet.Cells["B4"].Value = "radzen-blazor on GitHub";
        sheet.Cells["B4"].Hyperlink = new Hyperlink { Url = "https://github.com/radzenhq/radzen-blazor", Text = "radzen-blazor on GitHub" };
        sheet.Cells["B4"].Format = new Format { Color = "#1565c0", Underline = true };

        // Email
        sheet.Cells["A5"].Value = "Email Link";
        sheet.Cells["B5"].Value = "Send Email";
        sheet.Cells["B5"].Hyperlink = new Hyperlink { Url = "mailto:info@radzen.com", Text = "Send Email" };
        sheet.Cells["B5"].Format = new Format { Color = "#1565c0", Underline = true };

        // Documentation
        sheet.Cells["A6"].Value = "Documentation";
        sheet.Cells["B6"].Value = "Blazor Documentation";
        sheet.Cells["B6"].Hyperlink = new Hyperlink { Url = "https://learn.microsoft.com/en-us/aspnet/core/blazor/", Text = "Blazor Documentation" };
        sheet.Cells["B6"].Format = new Format { Color = "#1565c0", Underline = true };

        // NuGet
        sheet.Cells["A7"].Value = "NuGet Package";
        sheet.Cells["B7"].Value = "Radzen.Blazor on NuGet";
        sheet.Cells["B7"].Hyperlink = new Hyperlink { Url = "https://www.nuget.org/packages/Radzen.Blazor", Text = "Radzen.Blazor on NuGet" };
        sheet.Cells["B7"].Format = new Format { Color = "#1565c0", Underline = true };

        // --- Images Section ---
        sheet.MergedCells.Add(RangeRef.Parse("A9:C9"));
        sheet.Cells["A9"].Value = "Images";
        sheet.Cells["A9"].Format = sectionFormat;
        sheet.Rows[8] = 28;

        sheet.MergedCells.Add(RangeRef.Parse("A10:C10"));
        sheet.Cells["A10"].Value = "Use the Insert > Image toolbar button to add images to the spreadsheet.";
        sheet.Cells["A10"].Format = noteFormat;

        sheet.MergedCells.Add(RangeRef.Parse("A11:C11"));
        sheet.Cells["A11"].Value = "Images can be moved by dragging and resized using the selection handles.";
        sheet.Cells["A11"].Format = noteFormat;

        // --- Hyperlink tips ---
        sheet.MergedCells.Add(RangeRef.Parse("A13:C13"));
        sheet.Cells["A13"].Value = "Tips";
        sheet.Cells["A13"].Format = sectionFormat;
        sheet.Rows[12] = 28;

        sheet.MergedCells.Add(RangeRef.Parse("A14:C14"));
        sheet.Cells["A14"].Value = "Use Insert > Hyperlink from the toolbar to add links interactively.";
        sheet.Cells["A14"].Format = noteFormat;

        sheet.MergedCells.Add(RangeRef.Parse("A15:C15"));
        sheet.Cells["A15"].Value = "Hyperlinks support URLs, email addresses (mailto:), and display text.";
        sheet.Cells["A15"].Format = noteFormat;

        sheet.EndUpdate();
    }
}