|114773||Dec 7,2013 03:57 PM UTC||Sep 3,2014 06:20 AM UTC||ASP.NET Web Forms (Classic)||7|
I am developing reports in Excel using Syncfusion xlsio for asp.net.
I would like to know how to configure the number format when change the regional Setting, example in es-ES the decimal symbol is the comma (,) but in en-US is the point (.)
Another example in es-ES have 1200,50 but in en-US this number change to 120050
We have tried in different scenarios and are unable to reproduce the issue. Could you please modify the attached sample to reproduce the issue and send us back? It will be helpful to us to analyze further on this. We would request you to use our Direct-Trac Support system for further follow up.
Please let us know if you need any
Thank you for updating us.
Your machine culture seems to be in Spanish and you are trying to import data and generate the file in US culture In that case, the output is similar to the one you have shared. This can be resolved by setting decimal separator to the required culture. This can be achieved by the highlighted line in the following code snippets.
private void btnCreateExcel_Click(object sender, System.EventArgs e)
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel97to2003;
IWorkbook workbook = application.Workbooks.Open(@"../../Data/Sample.xls", ExcelOpenType.Automatic);
IWorksheet sheet = workbook.Worksheets;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
//System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-ES");
application.DecimalSeparator = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
sheet.ImportDataTable(GetDataTable(), true, 1, 1, false);
workbook.Version = ExcelVersion.Excel97to2003;
string fileName = @"../../Output/Output.xls";
private DataTable GetDataTable()
DataTable dt = new DataTable("Data");
DataRow dr1 = dt.NewRow();
dr1["PRECIO"] = 1253.53;
dt.Rows.Add(dt.NewRow()["PRECIO"] = 1253.53);
dt.Rows.Add(dt.NewRow()["PRECIO"] = 2848.94);
dt.Rows.Add(dt.NewRow()["PRECIO"] = 3112.01);
dt.Rows.Add(dt.NewRow()["PRECIO"] = 3219.3);
dt.Rows.Add(dt.NewRow()["PRECIO"] = 784.77);
dt.Rows.Add(dt.NewRow()["PRECIO"] = 1139.58);
dt.Rows.Add(dt.NewRow()["PRECIO"] = 1271.87);
dt.Rows.Add(dt.NewRow()["PRECIO"] = 723.77);
Kindly try this approach and get back to us if the issue is resolved.
Thank you for updating us.
The issue you encountered occurs in versions prior to 12.1. if your working version is beyond 12.1, we strongly recommend you to upgrade to the latest version 12.2 which has more features and enhancements.
Latest Version: https://www.syncfusion.com/support/forums/announcements/116964
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.