Telerik Forums
UI for ASP.NET Core Forum
1 answer
37 views
Hi Team,

I am facing an issue where formulas in the spreadsheet are not properly reflecting when importing or downloading sheets in my application. Specifically, the formulas are not retained during the upload process or included correctly during the export/download operation.

Below are the reference codes for upload and download functionality:

Upload Code:
using (var package = new ExcelPackage(stream))
{
    var workbook = package.Workbook;
    var worksheet = workbook.Worksheets[0];

    var rows = new List<dynamic>();
    for (int row = 1; row <= worksheet.Dimension.End.Row; row++)
    {
        var rowData = new List<string>();
        for (int col = 1; col <= worksheet.Dimension.End.Column; col++)
        {
            rowData.Add(worksheet.Cells[row, col].Text);
        }
        rows.Add(new { cells = rowData.Select(val => new { value = val }).ToArray() });
    }

    var sheetData = new
    {
        name = worksheet.Name,
        rows = rows.ToArray()
    };

    return Json(new { success = true, data = sheetData });
}



Download Code:
using (var package = new ExcelPackage())
{
    var sheet = spreadsheetData.sheets.FirstOrDefault();
    if (sheet != null)
    {
        var worksheet = package.Workbook.Worksheets.Add(sheet.name);

        foreach (var row in sheet.rows)
        {
            foreach (var cell in row.cells)
            {
                var excelCell = worksheet.Cells[row.index + 1, cell.index + 1];

                // Set font properties
                excelCell.Style.Font.Size = cell.fontSize > 0 ? cell.fontSize : sheet.defaultCellStyle.fontSize;
                excelCell.Style.Font.Bold = cell.bold;

                // Set background color
                if (!string.IsNullOrEmpty(cell.background))
                {
                    excelCell.Style.Fill.PatternType = ExcelFillStyle.Solid;
                    excelCell.Style.Fill.BackgroundColor.SetColor(ColorTranslator.FromHtml(cell.background));
                }

                // Set font color
                if (!string.IsNullOrEmpty(cell.color))
                {
                    excelCell.Style.Font.Color.SetColor(ColorTranslator.FromHtml(cell.color));
                }

                // Set text alignment
                excelCell.Style.HorizontalAlignment = cell.textAlign switch
                {
                    "center" => ExcelHorizontalAlignment.Center,
                    "right" => ExcelHorizontalAlignment.Right,
                    _ => ExcelHorizontalAlignment.Left,
                };

                // Set number format
                if (!string.IsNullOrEmpty(cell.format))
                {
                    excelCell.Style.Numberformat.Format = cell.format;
                }

                // Set formula if available
                excelCell.Formula = cell.formula;
                
                // Set cell value
                excelCell.Value = cell.value;
            }
        }
    }

    fileStream = new MemoryStream(package.GetAsByteArray());
}


Could you please guide me on resolving this issue to ensure formulas are preserved and processed accurately?

Thank you for your assistance!
Anton Mironov
Telerik team
 answered on 14 Jan 2025
2 answers
66 views

I need to be able to render a tabstrip with a dynamic number of tabs, and then within each tab a griid to display records that relate to the tab.

Basically it is grouping sets of data into tabs, and then displaying the records from that group in the grid.

The underlying source of the grids is all the same, albeit each one would be showing a different subset of records.

The number of tabs/grids required would be unknown until the data is loaded.

Is this even possible? I have searched but can't find an example doing exactly what I need.

Thanks

Chris
Top achievements
Rank 1
Iron
Iron
Iron
 updated answer on 10 Jan 2025
0 answers
57 views

Hi,

How to save the layout of the dockmanager ? I need to restore panels in the right place.

Best regards

Yohann
Top achievements
Rank 1
 asked on 09 Jan 2025
2 answers
425 views

I can't seem to get the Cascading DropdownList functionality to return the selected value from the parent.  I will list what I have and if someone can point out my problem I would appreciate it.  The parent loads the selected items correctly, and it calls the child dropdownlist event when a new select is made, but the parameter that should have the selected id is always null.

.cshtml page

<table><tr>
        <td>CLIN:</td>
        <td>

                <kendo-dropdownlist name="ddlCLIN"  datatextfield="Title" datavaluefield="ProjectID" >
                    <datasource type="DataSourceTagHelperType.Custom">
                        <transport>
                            <read url="/LogEditor?handler=CLINS" />
                        </transport>
                    </datasource>

                </kendo-dropdownlist>
            </td>
    </tr>
    <tr>
        <td>CLIN Task Type:</td>
        <td>
            <kendo-dropdownlist name="ddlCLINTaskType" cascade-from="ddlCLIN" datatextfield="Title" datavaluefield="ProjectID">
                <datasource type="DataSourceTagHelperType.Custom">
                    <transport>

                        <read url="/LogEditor?handler=CLINTaskTypes" />

                    </transport>
                </datasource>

            </kendo-dropdownlist>
        </td>
    </tr></table>

 

html.cs

 

public JsonResult OnGetCLINTaskTypes(int? ddlCLIN)
        {
            TaskTypes tt = new TaskTypes(SQLWrapper);
            DataSet ds = new DataSet();
            
            
            if(ddlCLIN == null)
            {
                ddlCLIN = 0;
            }
            ds = tt.SelectRecordsForDropDown("TITLE", Int32.Parse(HttpContext.Session.GetInt32(Globals.SessionName.Org.ToString()).ToString()), ddlCLIN);

            List<Projects> list = new List<Projects>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                list.Add(new Projects(SQLWrapper)
                {
                    ProjectID = Convert.ToInt32(dr["TYPE_ID"].ToString()),
                    Title = dr["TITLE"].ToString(),


                });
            }


            var dsResult = list;//.ToDataSourceResult(request);
            return new JsonResult(dsResult);
            
            
        }
        public JsonResult OnGetCLINS()
        {
            Projects Projdb = new Projects(SQLWrapper);
            DataSet ds = new DataSet();
            ds = Projdb.SelectRecordsForDropDown("TITLE", Int32.Parse(HttpContext.Session.GetInt32(Globals.SessionName.Org.ToString()).ToString()));

            List<Projects> list = new List<Projects>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                list.Add(new Projects(SQLWrapper)
                {
                    ProjectID = Convert.ToInt32(dr["PROJECT_ID"].ToString()),
                    Title = dr["TITLE"].ToString(),
    

                });
            }

           
            var dsResult = list;//.ToDataSourceResult(request);
            return new JsonResult(dsResult);
        }                                                                          
Viktor Tachev
Telerik team
 updated answer on 02 Jan 2025
1 answer
78 views
I am not able to see clear button aspnet core text box control. I have added clear-button="true" to textbox tag helper code and still not able to see the clear button when the data is entered in the text box.
Eyup
Telerik team
 answered on 25 Dec 2024
2 answers
44 views

Hi

I have a data bound menu component where I would like to override the styles of individual items - namely at the moment I would like to make some bold.

What I actually want to do is to render a separator, then a bold header, and then a normal weight list of options - something like :

-----------------------------
Recent Customers
Customer 1
Customer 2
Customer 3
-----------------------------

I do not want them to be a sub menu ideally. I am struggling to work out how to set the class/style of individual menu items.

This is my code for rendering the menu currently, I will add another property to item/subitem as a flag to denote requiring to be bold :

            @(
            Html.Kendo().Menu()
            .Name("mainMenu")                
            .BindTo(Model.Menus.Where(s => s.ParentMenuId == 0), mappings =>
            {
                mappings.For<Welcomm_CRM.Core.Application.Menu>(binding => binding // Define the first level of the Menu.
                .ItemDataBound((item, type) => // Define the mapping between the Menu item properties and the model properties.
                {
                    item.Text = type.MenuTitle;   
                    if (type.MenuSource == 999999)
                    {
                        item.LinkHtmlAttributes.Add(type.ControllerName, type.ActionName);
                    }
                    else if (type.MenuSource == 999998)
                    {
                        item.Separator = true;
                    }
                    else if (type.MenuSource == 0)
                    {
                        item.Url = @Html.Encode(type.Url);
                    }
                }
                )
                .Children(type => Model.Menus.Where(s => s.ParentMenuId == type.MenuId)));
                mappings.For<Welcomm_CRM.Core.Application.Menu>(binding => binding
                .ItemDataBound((item, subtype) =>
                {
                    item.Text = subtype.MenuTitle;                        
                    if (subtype.MenuSource == 999999)
                    {
                        item.LinkHtmlAttributes.Add(subtype.ControllerName, subtype.ActionName);
                    }
                    else if (subtype.MenuSource == 999998)
                    {
                        item.Separator = true;
                    }
                    else
                    {
                        item.Url = @Html.Encode(subtype.Url);
                    }
                })
                );
            })
            )

Chris
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 18 Dec 2024
1 answer
44 views

We have been using the grid control for quite some time and we just now noticed the logic we use to right-justify the header text appears to not be styling as intended.  I have attached a screen shot to show the odd display.  The text is right-justified but the header text is still on the left of the column.  I should note it is common practice, especially for reports, to right justify both the text and the header when showing numeric values so the decimals align.

<column field="CurrentOverCount" title="Over<br />Employee Count" width="70"
        header-html-attributes='new Dictionary<string,object> { ["class"]="text-end" }' html-attributes='new Dictionary<string,object> { ["class"]="text-end" }' />

I have also tried using pure CSS for the header with the same result:

<column field="CurrentOverCount" title="Over<br />Employee Count" width="70"
        header-html-attributes='new Dictionary<string,object> { ["style"]="text-align:right;" }' html-attributes='new Dictionary<string,object> { ["class"]="text-end" }' />

Alexander
Telerik team
 answered on 18 Dec 2024
1 answer
109 views

@(Html.Kendo().Menu()
  .Name("Menu")
  .Items(items =>
  {
      items.Add()
              .Text("Products - Expand me")
              .Items(children =>
              {
                  children.Add().Text("Furniture");

                  children.Add().Encoded(false).Text("<span class=\"k-icon k-i-clock\"></span>I have a Font Icon");

                  children.Add().Text("Decor");

              });

      items.Add().Text("Stores");
  })
)
The above code does not render the icon.  All the examples in the demos are with Images. Latest update broke my application. What is the new way to achieve this?
Eyup
Telerik team
 answered on 16 Dec 2024
1 answer
38 views

My app has a static footer bar, and in the bottom left of all pages I want to add a button which will launch the users "To Do List", ideally also down in the bottom left hand corner.

Obviously the content within that will be dynamic, and will likely be a list of items to attend to, groups by type, which will actually just be links off the various other pages.

What is the best way to achieve the pop up To Do List? I was looking at the Action Sheet, but the position / sizing is off, as I can only seem to have it open in the centre of the screen, or full width.

Eyup
Telerik team
 answered on 15 Dec 2024
1 answer
39 views

Let's say I have a Telerik Wizard With Three Steps and I am passing a View Model to each step. In Step 1, A Telerik Form component would suffice. But, In Step 2, I need to have more specific control over the layout and function than what the Form Component provides. I would like to use custom MVC Razor View syntax for Step 2, for example:

 <div class="form-group">
                <label asp-for="Title" class="control-label"></label>
                <input asp-for="Title" class="form-control" />
                <span asp-validation-for="Title" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Rating" class="control-label"></label>
                <input asp-for="Rating" class="form-control" />
                <span asp-validation-for="Rating" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="ReleaseDate" class="control-label"></label>
                <input asp-for="ReleaseDate" class="form-control" />
                <span asp-validation-for="ReleaseDate" class="text-danger"></span>
            </div>

Is this something that is possible and would I preserve the View Models state between steps? I'm not exactly finding a clear solution in the documentation. Any help or an example of how this could be done would be appreciated!

Eyup
Telerik team
 answered on 10 Dec 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?