C#:Excel 缅甸字体数据的导出不正确
C#: Excel export doesn't show correctly for Myanmar Font data
我正在尝试将数据表数据作为 CSV 文件获取。但是缅甸字体的数据在excel中显示不正确。显示为如下字符。
"လá'်း áႠလေးပုံá€á€•ုံ á'á €¼á€á€¯á€·”
我附上了我的代码。
DataTable dt = ToDataTable(objList);
StringBuilder sb = new StringBuilder();
IEnumerable<string> columnNames = dt.Columns.Cast<DataColumn>().
Select(column => column.ColumnName);
sb.AppendLine(string.Join(",", columnNames));
foreach (DataRow row in dt.Rows)
{
IEnumerable<string> fields = row.ItemArray.Select(field => field.ToString());
sb.AppendLine(string.Join(",", fields));
}
string folderPath = HttpContext.Current.Server.MapPath("/Files") + "/Files/Export/";
File.WriteAllText(folderPath + "Export.csv", sb.ToString());
替换
File.WriteAllText(folderPath + "Export.csv", sb.ToString());
有
File.WriteAllText(folderPath + "Export.csv", sb.ToString(), Encoding.Unicode);
The Myanmar script was added to the Unicode Standard in Version 3.0 (September, 1999). Version 5.2 significantly extended the script in 2009
我正在尝试将数据表数据作为 CSV 文件获取。但是缅甸字体的数据在excel中显示不正确。显示为如下字符。
"လá'်း áႠလေးပုံá€á€•ုံ á'á €¼á€á€¯á€·” 我附上了我的代码。
DataTable dt = ToDataTable(objList);
StringBuilder sb = new StringBuilder();
IEnumerable<string> columnNames = dt.Columns.Cast<DataColumn>().
Select(column => column.ColumnName);
sb.AppendLine(string.Join(",", columnNames));
foreach (DataRow row in dt.Rows)
{
IEnumerable<string> fields = row.ItemArray.Select(field => field.ToString());
sb.AppendLine(string.Join(",", fields));
}
string folderPath = HttpContext.Current.Server.MapPath("/Files") + "/Files/Export/";
File.WriteAllText(folderPath + "Export.csv", sb.ToString());
替换
File.WriteAllText(folderPath + "Export.csv", sb.ToString());
有
File.WriteAllText(folderPath + "Export.csv", sb.ToString(), Encoding.Unicode);
The Myanmar script was added to the Unicode Standard in Version 3.0 (September, 1999). Version 5.2 significantly extended the script in 2009