Completed
Last Updated: 28 Jan 2025 12:35 by ADMIN
Release 2025 Q1 (Feb)
ADMIN
Marin Bratanov
Created on: 26 Dec 2017 14:31
Category: Spreadsheet
Type: Bug Report
1
Default font size is not saved and loaded to/from Excel

The default font size on the client is not saved explicitly on the Excel file, so the Excel defaults take over (11px Calibri), so upon subsequent import all cells will have that font. Steps to repro: go to https://demos.telerik.com/aspnet-ajax/spreadsheet/examples/import-export/defaultcs.aspx export the file import the file Expected: nothing changes Actual: all cells are 11px Calibri

Workaround: Set a default font when the cell font is null

 

public override void SaveWorkbook(Workbook workbook)
{
    string path = "C:\\path-to-output.xlsx";
     
    for (int i = 0; i < workbook.Sheets.Count; i++)
    {
        for (int j = 0; j < workbook.Sheets[i].Rows.Count; j++)
        {
            for (int l = 0; l < workbook.Sheets[i].Rows[i].Cells.Count; l++)
            {
                string fontFamily = workbook.Sheets[i].Rows[i].Cells[l].FontFamily;
                workbook.Sheets[i].Rows[i].Cells[l].FontFamily = !string.IsNullOrEmpty(fontFamily) ? fontFamily : "Courier New";
 
                double? fontSize = workbook.Sheets[i].Rows[i].Cells[l].FontSize;
                workbook.Sheets[i].Rows[i].Cells[l].FontSize = fontSize.HasValue ? fontSize : 12;
            }
        }
    }
    workbook.Save(path);
}

 

1 comment
ADMIN
Rumen
Posted on: 28 Jan 2025 12:35

Hi everyone,

The problem is fixed in the latest version.

 

Regards,
Rumen
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources