Hi there
I have a grid that exports to Excel, the data in the SQL Server table are NVARCHAR(4000) fields. It displays correctly, but when exporting it changes some of the diacritics to foreign characters, for example:
DB: André Letoit
Excel: Andr頌etoit
The code I am using to export is:
and
Is there any setting I need to change for this to keep the database characters?
Thank you.
I have a grid that exports to Excel, the data in the SQL Server table are NVARCHAR(4000) fields. It displays correctly, but when exporting it changes some of the diacritics to foreign characters, for example:
DB: André Letoit
Excel: Andr頌etoit
The code I am using to export is:
/// <summary>
/// Export the Grid to XLS on Server instead of Clientside
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
protected
void
uxExportRequests_GridExporting(
object
source, GridExportingArgs e)
{
User currentUser =
new
User(HttpContext.Current.User.Identity.Name.ToString());
string
fileName = currentUser.UserID.ToString() +
"_TitleRequests_"
+ DateTime.Now.ToShortDateString().Replace(
"/"
,
""
).Replace(
"-"
,
""
) +
".xls"
;
string
path = Server.MapPath(
"~/Requests/"
) + fileName;
using
(FileStream fs = File.Create(path))
{
Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
fs.Write(info, 0, info.Length);
}
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
uxExportRequests.GridLines = GridLines.Both;
uxExportRequests.GridExporting +=
new
OnGridExportingEventHandler(uxExportRequests_GridExporting);
uxExportRequests.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
uxExportRequests.ExportSettings.ExportOnlyData =
true
;
}
}
Thank you.