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 8065121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:34:22+00:00 2026-06-05T11:34:22+00:00

In a data grid I’m displaying numeric values formatted using a standard format string,

  • 0

In a data grid I’m displaying numeric values formatted using a standard format string, “N02” in this case. When I export this data to excel, I’d like to format the excel column the same. Is there a way to evaluate the “N02” format for the current locale and get the actual format string?

If not, I’m thinking I’d have to try and reconstruct it using NumberNegativePattern, NumberGroupSizes, NumberGroupSeparator, and NumberDecimalSeparator properties of the current NumberFormat but I really don’t like my chances of getting that right for my than my locale/culture.

This is what I want to set for my Excel interop call:

((Range)excelSheet.Columns[columnLetter + “:” + columnLetter, Type.Missing]).NumberFormat = xxxxx;

I’d like xxxxx for both “N” and for “N02”, I know I can use something like this:
“#,##0.00;-#,##0.00” for “N02”
But that’s made the whole thing culture specific.

  • 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-06-05T11:34:23+00:00Added an answer on June 5, 2026 at 11:34 am

    The problem here is twofold; firstly, Excel interop exposes only a very limited set of functionality when it comes to working with number styles. Secondly, Excel itself pays little attention to culture-specific formatting.

    For example, in the Open XML standard for Excel, all of the built-in number format styles are hard-coded (see the ECMA standard document, page 2128). Although different styles are used according to the user’s locale, Excel does not pay attention to any overrides in the user’s regional settings like the .NET Framework’s globalization features do. Even if you were to marry-up the standard numeric format strings with their Excel equivalents (by region), the format could still differ due to the regional settings in Windows.

    As flindeberg mentioned in their comment, formatting the cell values as text is the only way to really be sure that the way your numbers are formatted in .NET is how they will be appear in Excel.

    Due to the limitations you’re working with, I would suggest targeting an invariant culture when generating spreadsheets, instead of trying to make specialisations for each culture. By sticking to the rules of the invariant culture, you can fairly easily write an algorithm to translate standard numeric format strings into their expanded form, for use with Excel.

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

Sidebar

Related Questions

BackGround: I have an advanced data grid. The data provider for this ADG is
I am using data grid view in Windows Form standalone application to display items
i am using a data grid in flex and i am generating data from
I am using a data grid and has bound a data source with it.
I am using wpf data grid which has template columns. i just want to
I have a data grid where I am displaying my messages. In that if
I have a data grid that looks like this <tk:DataGrid ItemsSource={Binding Parents} AutoGenerateColumns=False> <tk:DataGrid.Columns>
i am using data grid view in C# winforms, lets say there are n
I have a data grid and in that grid its making this call: <ItemTemplate>
In order to initialize my VouchersDGV Data Grid View I'm Using the following DGV.AllowUserToDeleteRows

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.