Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7676575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:13:50+00:00 2026-05-31T17:13:50+00:00

I have a document that my asp.net page is creating and I need to

  • 0

I have a document that my asp.net page is creating and I need to align the text of certain columns to center. I have opened the document after manually center the columns in openXML SDK but the code that is reflected does not achieve the desired outcome.

This is how I am setting the custom widths of these columns and I would like to add to this function (method, whatevs) the capability to center the text:

private static Column CreateColumnData(UInt32 StartColumnIndex, UInt32 EndColumnIndex, double ColumnWidth)
    {
        Column column;
        column = new Column();
        column.Min = StartColumnIndex;
        column.Max = EndColumnIndex;
        column.Width = ColumnWidth;
        column.CustomWidth = true;
        //the SDK says to add this next line to center the text but it doesn't work
        column.Style = (UInt32Value)6U;

        return column;
    }

I’m open to another way but I think that the solution has got to be very simple I just can’t seem to get it. If anyone can help that would be great.

NOTE: Please keep in mind that I am using OpenXML and will not be using Microsoft.Office.Interop.Excel

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:13:51+00:00Added an answer on May 31, 2026 at 5:13 pm

    I think the issue is that you are trying to style the column, when it is individual cells that need to be formatted to use a specific horizontal alignment.

    I looked around and found the following MSDN documentation:

    http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.cellformat_properties.aspx

    http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.alignment.aspx

    I also found a code example here (Though I didn’t test it myself):

    http://blogs.msdn.com/b/chrisquon/archive/2009/11/30/stylizing-your-excel-worksheets-with-open-xml-2-0.aspx

    I use the Interop most of the time myself, and know that I styled cells and not columns or rows when I wrote up my spreadsheets.

    You should be able to create a single style and just apply it a bunch of times to cells as you create them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net page that has a script:# var Show; $(document).ready(function () {
I have an ASP.Net site that streams back a PDF document after a postback
I have a C# ASP webpage that is creating a KML document, and it's
I have a simple JQuery enabled ASP.NET page: <script> $(document).ready(function() { $(#accordion).accordion(); }); </script>
I have a CascadingDropDown on an ASP.NET page. Now, the prompt text is Select
I have an ASP.net mvc page that executes a jquery script on load. The
I've made a asp.net page that creates an Excel workbook. I have set the
I have an anchor tag on an ASP.NET page, whose text (inner HTML) I
The background to this is that we have a ASP.NET master page that reads
I have an ASP.NET page that uses a repeater nested within another repeater to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.