none
Column width Using openXML in C# RRS feed

  • Question

  • Hi,

    Please explain, how to set two different width to two different cells (A,E) in the excel sheet using openXML in C#.

    thanks,

    Elangovan P

    Thursday, December 15, 2011 1:25 PM

Answers

  • Hi Elangovan,

    Thanks for your post.

    I'm going to change the type of this thread to question as you are asking something about Open XML.

    For your question, if download Open XML SDK tool to reflect the format of a workbook to C#, you would see something like:

    public Columns GenerateColumns()
            {
                Columns columns1 = new Columns();
                Column column1 = new Column(){ Min = (UInt32Value)1U, Max = (UInt32Value)1U, Width = 23.28515625D, CustomWidth = true };
    
                Column column2 = new Column(){ Min = (UInt32Value)5U, Max = (UInt32Value)5U, Width = 64.7109375D, CustomWidth = true };
    
                columns1.Append(column1);
                columns1.Append(column2);            
                return columns1;
            }
    

    The above code is how to specify column width for column A and E by using OpenXML and C# code.

    Good day,


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us
    Friday, December 16, 2011 7:04 AM
    Moderator

All replies

  • Hi,

    Please explain, how to set two different width to two different columns (A,E) in the excel sheet using openXML in C#.

    thanks,

    Elangovan P

    Friday, December 16, 2011 4:41 AM
  • Hi Elangovan,

    Thanks for your post.

    I'm going to change the type of this thread to question as you are asking something about Open XML.

    For your question, if download Open XML SDK tool to reflect the format of a workbook to C#, you would see something like:

    public Columns GenerateColumns()
            {
                Columns columns1 = new Columns();
                Column column1 = new Column(){ Min = (UInt32Value)1U, Max = (UInt32Value)1U, Width = 23.28515625D, CustomWidth = true };
    
                Column column2 = new Column(){ Min = (UInt32Value)5U, Max = (UInt32Value)5U, Width = 64.7109375D, CustomWidth = true };
    
                columns1.Append(column1);
                columns1.Append(column2);            
                return columns1;
            }
    

    The above code is how to specify column width for column A and E by using OpenXML and C# code.

    Good day,


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us
    Friday, December 16, 2011 7:04 AM
    Moderator