C1FlexSheet: why does the UI use different font sizes than the loaded file?

Posted by: mark.smeltzer on 28 January 2020, 12:25 pm EST

    • Post Options:
    • Link

    Posted 28 January 2020, 12:25 pm EST

    I’ve created a workbook using C1XLBook APIs and the fonts, formatting, sizing, etc. all look good in Excel.

    However, when that same file is loaded into C1FlexSheet, the font settings from the file don’t seem to be used… This causes the text in the UI to render quite large and as a result, the text wrapping in the UI is totally off. Moreover, on cells that don’t wrap the text is cut off.

    Questions:

    1. How can I make C1FlexSheet respect the font settings in the loaded file?
    2. Would I have to manually do adjustments post load using styles?!
  • Posted 28 January 2020, 8:46 pm EST

    Hello,

    I am not able to replicate the issue using the folloiwng line of code:

    flexsheet.Load(new System.IO.FileStream("test.xlsx", System.IO.FileMode.Open), C1.WPF.FlexGrid.ImportFileFormat.XLSX);
    

    Please refer to the attached xlsx file created through C1XLbook.

    Thanks,

    Mohit

    test.zip

  • Posted 29 January 2020, 7:46 am EST - Updated 3 October 2022, 11:58 pm EST

    The issue is very easy to reproduce.

    Excel:

    WPF UI:

    Notice how the font sizes are wrong in WPF, which causes the wrapping and layout to be broken. The font on these cells in Excel is sent to 10pt and the cells are sized to produce the desired wrapping and fit. However, when the same file is loaded into C1FlexSheet, the wrapping and layout are all wrong.

    I believe this is simply a font issue. I don’t think the C1FlexSheet is using the font sizes from the file (and possibly not the font family either?). I can verify the font sizes are incorrect using the Live XAML tree.

    Here we can see the font size from the loaded file is 16 in WPF, which is not correct:

    If I manually tweak that down to font size 13 in WPF, I get the expected wrapping:

    It seems that C1FlexSheet should set the WPF font sizes appropriately when loading the file (probably some conversion function is necessary) so that content fits into the cells in the UI.

  • Posted 29 January 2020, 7:56 am EST - Updated 3 October 2022, 11:58 pm EST

    I found that if I save the Excel file with font sizes decreased by 2 points, C1FlexSheet displays as desired. So, that means that C1FlexSheet is setting the font too large on load. Not good.

    I don’t want to have to preload all Excel files, decrease font size by 2 points, resave to temp streams and then load them to C1FlexStream – that’s crazy.

    Especially since the files saved by C1FlexSheet also have the same issue: if the column sizes are set to be what looks proper in C1FlexSheet, the columns will be way too wide when saved and then opened in Excel.

    Also, notice another issue: C1FlexSheet is incorrectly rendering some plain text number as formatted numbers. Also not good! The UI should match the Excel file – if the number isn’t formatted in Excel, it is treated as “General” format which is effectively the same as plaintext.

  • Posted 29 January 2020, 8:06 am EST

    Here’s the file I used: test.zip

  • Posted 29 January 2020, 8:07 am EST

    Actually the file above was the test with text saved as 8pt. This file has the desired 10pt font: test-10pt.zip

  • Posted 29 January 2020, 3:41 pm EST - Updated 3 October 2022, 11:58 pm EST

    In fact, the whole C1FlexSheets UI has very large fonts – it defaults everything to font size 16. That includes the row numbers, etc.

    For example, I found that column headers have a drop down for filtering, etc., but it has huge fonts and doesn’t look right:

    My app does not have any theme applied. I tried applying some of the themes, but they made all of the text in my whole app larger, and didn’t fix these other issues either.

  • Posted 29 January 2020, 3:44 pm EST

    FYI, I am using the latest release of the WPF components…

  • Posted 3 February 2020, 12:55 am EST

    Hello,

    I am able to observe the issue at my end. I have escalated the issue to our development team (419403)and will inform you once I get any updates from them.

    Thanks,

    Mohit

  • Posted 3 February 2020, 2:12 pm EST

    Thanks.

  • Posted 16 March 2020, 11:47 pm EST

    Hi,

    This is to inform you that the issue has been fixed in the latest build (i.e. 2020v1). You can get the latest builds from http://prerelease.componentone.com/dotnet452/c1wpflibrary/2020-t1/C1WPFBasicLibrary.4.5.2_4.5.20201.697.zip.

    Regards,

    Basant

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels