Hi all,
I'm exporting a datagrid to an excel file.
I'm using the following source code to export
DataTable dt = new DataTable();
DataAccess.Stor edProcedure sproc = new
DataAccess.Stor edProcedure("sp roc_getdata");
sproc.Run(dt);
DataGrid1.DataS ource = dt;
DataGrid1.DataB ind();
DataGrid1.Enabl eViewState = false;
DataGrid1.Visib le = true;
DataGrid1.GridL ines = GridLines.Both;
Response.Clear( );
Response.Buffer = true;
Response.AddHea der( "Content-Disposition", "filename=File1 .xls");
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter( stringWriter);
DataGrid1.Rende rControl(htmlWr iter);
Response.Write( stringWriter.To String());
Response.Conten tType="applicat ion/vnd.ms-excel";
Response.End();
Its working fine.
but there is an isuue datagrid contains extended language
strings(like chinese, japanese).These stringsare not getting exported
into excel.
DataGrid is getting data from SQLServer2005 database. I know that
sqlserver is using utf-16 encoding for unicode character. So i've tried
to change Response.Conten tEncoding to utf-16. But it is also not
working.
Can anyone help me.
I'm exporting a datagrid to an excel file.
I'm using the following source code to export
DataTable dt = new DataTable();
DataAccess.Stor edProcedure sproc = new
DataAccess.Stor edProcedure("sp roc_getdata");
sproc.Run(dt);
DataGrid1.DataS ource = dt;
DataGrid1.DataB ind();
DataGrid1.Enabl eViewState = false;
DataGrid1.Visib le = true;
DataGrid1.GridL ines = GridLines.Both;
Response.Clear( );
Response.Buffer = true;
Response.AddHea der( "Content-Disposition", "filename=File1 .xls");
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter( stringWriter);
DataGrid1.Rende rControl(htmlWr iter);
Response.Write( stringWriter.To String());
Response.Conten tType="applicat ion/vnd.ms-excel";
Response.End();
Its working fine.
but there is an isuue datagrid contains extended language
strings(like chinese, japanese).These stringsare not getting exported
into excel.
DataGrid is getting data from SQLServer2005 database. I know that
sqlserver is using utf-16 encoding for unicode character. So i've tried
to change Response.Conten tEncoding to utf-16. But it is also not
working.
Can anyone help me.
Comment