none
How to set vertical alignment and line folding for excel cell? RRS feed

Answers

All replies

  • I thought it's usual thing. But nobody knows.
    • Edited by guy222 Monday, April 23, 2012 11:56 AM
    Monday, April 23, 2012 11:51 AM
  • WorkbookStylesPart sp = workbookpart.AddNewPart<WorkbookStylesPart>("rId3");
                sp.Stylesheet = new Stylesheet();
                workbookpart.WorkbookStylesPart.Stylesheet.CellFormats = new CellFormats();
                CellFormat cellFormat1 = new CellFormat()
                {
                    NumberFormatId = (UInt32Value)0U,
                    FontId = (UInt32Value)0U,
                    FillId = (UInt32Value)0U,
                    BorderId = (UInt32Value)0U,
                    FormatId = (UInt32Value)0U,
                    ApplyAlignment = true,
                    Alignment = new Alignment() { Vertical = VerticalAlignmentValues.Center, WrapText = true }
                };
                workbookpart.WorkbookStylesPart.Stylesheet.CellFormats.AppendChild<CellFormat>(cellFormat1);
                workbookpart.WorkbookStylesPart.Stylesheet.CellFormats.Count = UInt32Value.FromUInt32((uint)sp.Stylesheet.CellFormats.ChildElements.Count);
    What's wrong?
    Monday, April 23, 2012 12:43 PM
  • Hi Maxim,

    Thanks for posting in the MSDN Forum.

    I'm not sure about the mean of "line folding", would you please clarify it. It will make more sense if you show me a screen shooting.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 24, 2012 2:50 AM
    Moderator
  • And ability to set column width.

    Thanks for reply.


    • Edited by guy222 Tuesday, April 24, 2012 4:37 AM
    Tuesday, April 24, 2012 4:37 AM
  • When I work with existing file it's ok, but when I create file at runtime I can't open it.

    Tuesday, April 24, 2012 7:25 AM
    • Marked as answer by guy222 Tuesday, April 24, 2012 12:33 PM
    Tuesday, April 24, 2012 12:33 PM
  • Hi guy222,

    I think you did not added the fonts and other specification. If font border etc is your problem then add this code.

                var font1 = new Font();
                
                var bold1 = new Bold();
                var fontSize1 = new FontSize { Val = 11D };
                var color1 = new Color { Theme = (UInt32Value)1U };
                var fontName1 = new FontName { Val = "Arial" };
                var fontFamilyNumbering1 = new FontFamilyNumbering { Val = 2 };
                var fontScheme1 = new FontScheme { Val = FontSchemeValues.Minor };
                
                
                font1.Append(bold1);
                font1.Append(fontSize1);
                font1.Append(color1);
                font1.Append(fontName1);
                font1.Append(fontFamilyNumbering1);
                font1.Append(fontScheme1);
                fonts1.Append(font1);

    Thanks

    Tuesday, December 10, 2019 9:23 AM