Michael Lawrence
Top achievements
Rank 1
Michael Lawrence
asked on 10 Dec 2009, 01:11 AM
Hi all,
We're displaying plain text with line breaks in a GridView, and while the data is displayed correctly in the grid, all line breaks are stripped out when we export to Word or Excel using ToExcelML or ToHtml. This is occurring in the Q2 2009 build with Silverlight 2 - and unfortunately, moving to Silverlight 3 is not an option at present.
Has anyone else encountered this problem and, if so, do you have any suggestions or fixes?
Thanks,
Tony
6 Answers, 1 is accepted
0
Accepted
Hello Tony Kamboukos,
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Currently our GridView does not support multiline values export. However we can consider adding it in the future releases. Meanwhile I can suggest you alternative by directly manipulate the output result from exporting.
Please check the attached project for reference.
All the best,Tsvyatko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Michael Lawrence
Top achievements
Rank 1
answered on 11 Dec 2009, 02:26 AM
Fantastic! Thanks very much.
Would be awesome to see this in a future version.
0
Rob
Top achievements
Rank 1
answered on 13 Oct 2011, 07:49 PM
Hello,
Does anybody know if this feature has been included in the latest version? I'm using version 2011.2.920.1040.
Thanks.
Does anybody know if this feature has been included in the latest version? I'm using version 2011.2.920.1040.
Thanks.
0
Hi,
Vlad
the Telerik team
Such feature is not included in this version - you can use the approach from the posted project.
Kind regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Mark
Top achievements
Rank 2
answered on 26 Jul 2013, 04:32 AM
We had the same issue when exporting data to excel using the html format and using a .xls extension. I created a similar solution placing string tags within the grid exporting event, and then replaced the contents with the proper html tags.
private
static
readonly
string
LINE_BREAK_SYMBOL =
"[[LINEBREAK]]"
;
private
static
readonly
string
EXCEL_LINE_BREAK = @
"<br style="
"mso-data-placement:same-cell;"
">"
;
private
static
readonly
string
BOLD_SYMBOL_OPEN =
"[[BOLD_OPEN]]"
;
private
static
readonly
string
BOLD_SYMBOL_CLOSE =
"[[BOLD_CLOSE]]"
;
private
static
readonly
string
ITALIC_SYMBOL_OPEN =
"[[ITALIC_OPEN]]"
;
private
static
readonly
string
ITALIC_SYMBOL_CLOSE =
"[[ITALIC_CLOSE]]"
;
private
void
ExportToExcel()
{
string
selectedExportFormat =
"Excel"
;
string
extension =
"xls"
;
var format = ExportFormat.Html;
var dialog =
new
SaveFileDialog();
dialog.DefaultExt = extension;
dialog.Filter = String.Format(
"{1} files (*.{0})|*.{0}|All files (*.*)|*.*"
, extension, selectedExportFormat);
dialog.FilterIndex = 1;
if
(dialog.ShowDialog() ==
true
)
{
using
(var stream = dialog.OpenFile())
{
string
content =
null
;
var exportOptions =
new
GridViewExportOptions();
exportOptions.Format = format;
exportOptions.ShowColumnHeaders =
true
;
exportOptions.ShowGroupFooters =
true
;
exportOptions.Encoding = Encoding.UTF8;
using
(MemoryStream ms =
new
MemoryStream())
{
this
.gridView.Export(ms, exportOptions);
ms.Position = 0;
using
(StreamReader reader =
new
StreamReader(ms))
{
content = reader.ReadToEnd();
}
}
string
newContent = content.Replace(LINE_BREAK_SYMBOL, EXCEL_LINE_BREAK);
newContent = newContent.Replace(BOLD_SYMBOL_OPEN,
"<b>"
);
newContent = newContent.Replace(BOLD_SYMBOL_CLOSE,
"</b>"
);
newContent = newContent.Replace(ITALIC_SYMBOL_OPEN,
"<i>"
);
newContent = newContent.Replace(ITALIC_SYMBOL_CLOSE,
"</i>"
);
byte
[] messageBytes = UnicodeEncoding.UTF8.GetBytes(newContent);
stream.Write(messageBytes, 0, messageBytes.Length);
}
}
}
0
Hi Rob,
Didie
the Telerik team
Thank you for sharing the solution you implemented in your project with the community.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>