How to Apply a Locale to Excel Numbers and Dates When Exporting with C#
Question details
The user needs to export Excel-compatible workbooks from C# so that numbers and dates use the desired locale when displayed, without storing them as text.

- Product
- WPS Office Spreadsheets and Microsoft Excel
- Device & OS
- Windows
- Scenario
- A developer is exporting data from a C# application to an Excel file and wants the numbers and dates to appear with the correct decimal separators, thousands separators, and localized date names when the file is opened.
- Observed behavior
- Excel and WPS Office display numbers and dates according to the operating system's regional settings, not from a permanently embedded locale, and cell formatting alone cannot force every computer to use a specific locale.
Before exporting from C#, confirm that your source data is stored as numeric and DateTime types rather than pre-formatted strings, and decide which Excel number and date format codes you want to apply to each column.
Store Numbers and Dates as Native Values and Apply Excel Number Formats During C# Export
Use this method to create locale-aware Excel files that display correctly according to the user's regional settings.
Excel does not embed a locale in each cell. It stores the underlying value and a display format; the application then renders that format using the operating system's regional settings. If you export a string such as '1,234.56' or '12/31/2025', the cell may remain text and not respond to locale changes.
The reliable approach is to write raw numeric and date-time values, then apply Excel number formats such as #,##0.00 for numbers or dd/mm/yyyy for dates.
Open your C# project and go to the export method where cells are written. Replace any .ToString() or string.Format calls with the raw int, double, decimal, or DateTime value assigned directly to the cell.
In the same cell-assignment block, set the cell's Format or Style property to an Excel format code such as #,##0.00 for a number with two decimals or dd/mm/yyyy for a localized date.
Save the generated workbook as .xlsx from your C# application, then open it in WPS Office Spreadsheets or Excel and select the exported cells to inspect the display.
If the displayed decimal separator, thousands separator, or date order does not match the expected locale, go back to the export code, adjust the Excel format code, re-run the export, and reopen the file.

Check and Convert Cells That Were Exported as Text
Use this troubleshooting method when exported numbers or dates ignore regional settings or sorting and filtering behave unexpectedly.
Open and Validate Locale-Formatted Excel Workbooks in WPS Office
WPS Office cannot change the way Microsoft Excel stores locale information, but it is a free, lightweight, and easy-to-use alternative for opening, checking, and sharing .xlsx workbooks. It preserves Excel number and date formats, offers a familiar interface, and supports seamless migration from Microsoft Office.
- 1. Download and install WPS Office: Go to the official WPS website, click Download WPS Office Free, and install WPS Office on your Windows computer.
- 2. Open the exported Excel workbook: Launch WPS Office Spreadsheets, click Menu, choose Open, and select the .xlsx file exported from your C# application.
- 3. Check the number and date display: Select the numeric or date cells and open the Format Cells dialog from the Home tab to verify the Excel number format is applied and the values display according to the current regional settings.

Frequently Asked Questions
Why do Excel dates and numbers not use the locale I set in the cell format?
Cell formats define the display pattern, but Excel and WPS Office render localized symbols such as decimal separators, thousands separators, and month names using the operating system's regional settings. To make cells locale-aware, store values as numbers or true dates and apply an Excel format code during export.
Should I format numbers as strings in C# before exporting to Excel?
No. Exporting pre-formatted strings stores text, so the cells cannot automatically adapt to another user's locale or behave correctly in formulas. Write numeric or DateTime values and apply the Excel cell format instead.
Which Excel format codes should I use for localized numbers and dates?
For numbers, use codes such as #,##0.00. For dates, use codes such as dd/mm/yyyy or mmmm d, yyyy depending on the display you need. The actual decimal symbol and date names still come from the current regional settings.
Can I force Excel to always use a specific locale for every computer?
No. A single workbook cell does not permanently force a locale. Excel and WPS Office use the operating system's regional settings at open time. The reliable approach is to keep values numeric and use appropriate cell formats.
How can I check whether my exported cells are stored as text?
Open the file in WPS Office Spreadsheets, select the cells, and open the Format Cells dialog from the Home tab. If the category is Text, convert the values to Number or Date and reapply the format.




