none
Font Size problem RRS feed

  • Question

  • Hi,
    I get

    DocumentFormat.OpenXml.Spreadsheet.FontSize




    from 

                                            int fontId = Convert.ToInt32(cellFormat.FontId.Value);
                                            DocumentFormat.OpenXml.Spreadsheet.Font font = ss.Descendants<DocumentFormat.OpenXml.Spreadsheet.Font>().ElementAt(fontId);
                                            //Console.WriteLine("{0}: {1} fontSize is {2}", sheet.Name, cell.CellReference.Value, font.FontSize.Val.ToString());
                                            using (StreamWriter sw = new StreamWriter(@File1, true, Encoding.Unicode))
                                            {
                                                sw.WriteLine("{0}", font.FontSize.ToString());
                                            }



    How to get known what the exact size is?

    And I get
    <x:color indexed="64" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main" />


    from
                                            DocumentFormat.OpenXml.Spreadsheet.CellFormat cellFormat = cellFormats.Descendants<DocumentFormat.OpenXml.Spreadsheet.CellFormat>().ElementAt(styleIndex);
                                            try
                                            {
                                                DocumentFormat.OpenXml.Spreadsheet.Border border = wstylePart.Stylesheet.Elements<DocumentFormat.OpenXml.Spreadsheet.Borders>().First().Elements<DocumentFormat.OpenXml.Spreadsheet.Border>().ElementAt((int)(uint)cellFormat.BorderId);
                                                using (StreamWriter sw = new StreamWriter(@File1, true, Encoding.Unicode))
                                                {
                                                    if (border.LeftBorder.Elements<DocumentFormat.OpenXml.Spreadsheet.Color>().FirstOrDefault() != null)
                                                        sw.WriteLine("{0}", border.LeftBorder.InnerXml);



    is there one table showing exactly 64 is for which color?


    Many Thanks & Best Regards, Hua Min


    • Edited by Jackson_1990 Saturday, September 24, 2016 9:33 AM
    Saturday, September 24, 2016 9:11 AM

Answers

  • >>>How to get known what the exact size is?

    You could refer to below code:

    CellFormat cellFormat= wbPart.WorkbookStylesPart.Stylesheet.Elements<CellFormats>().First().Elements<CellFormat>().ElementAt((int)(uint)theCell.StyleIndex);
    Font font = wbPart.WorkbookStylesPart.Stylesheet.Elements<Fonts>().First().Elements<Font>().ElementAt((int)(uint)cellFormat.FontId);
    
    Console.WriteLine((double)font.FontSize.Val);

    >>>is there one table showing exactly 64 is for which color?

    You could refer to IndexedColors class

    Thanks for your understanding.

    • Marked as answer by Jackson_1990 Monday, September 26, 2016 3:10 AM
    Monday, September 26, 2016 2:48 AM