This question is locked. New answers and comments are not allowed.
Hi everyone,
Im facing consistent problems when exporting a GridView to Excel (im using MS Excel 2003 and Telerik version 2010.3.1314.1040). Ive also tested two exporting methods for each problems which ill refer below:
Method1:
Method2:
1-Aggregate/Grouping:
When im using header grouping and aggregate functions to summarized my grid. I would like to have that summarized view in my Excel. The problem is I have too much data displayed (the reason im using groupings) and I end up having all the grid rows exported...which I dont want. The worse are the aggregate totals for each group (sum, avg etc.) that are not exported. The ideal would be to export only the data that are visible....(not those folded and hidden by the groupings). With Method1, I get all the rows with no aggregate at all. With Method2, I get the same + the aggregate footer of the grid, but I also get weird code such as "[QCVG: Key=CM550FB240; ItemCount=2; HasSubgroups=False; ParentGroup=[QCVG: Key=Root; ItemCount=2; HasSubgroups=True; ParentGroup=null];];" in all columns of the last row.
2-Localizations
When im using French Canadian localization ("fr-CA"), im always getting weird characters for "special" letters (like "é", etc.) For instance the word "Équipement" becomes "Équipement". I also noted that when using {0:N4} as DataFormatString for particular numeric type columns (ex: 7,68), the export gives 76,80. Im forced to use default DataFormatString which use "." instead of "," but I lose the 4 digits limit.
Ive also attached a screenshot of the gridview (grouped and expanded) + exported .xls for each method (the first one is using french localization to demonstrate problem #2)
Can you help please?
Thanks in advance
Im facing consistent problems when exporting a GridView to Excel (im using MS Excel 2003 and Telerik version 2010.3.1314.1040). Ive also tested two exporting methods for each problems which ill refer below:
Method1:
Dim
dlgSave
As
New
SaveFileDialog()
dlgSave.Filter =
"Excel Files (*.xls)|*.xls"
dlgSave.DefaultExt =
"xls"
If
dlgSave.ShowDialog() =
True
Then
AddHandler
grdData.Exporting,
AddressOf
grd_Exporting
Dim
Content
As
String
Content = grdData.ToHtml(
True
)
RemoveHandler
grdData.Exporting,
AddressOf
grd_Exporting
Using stream
As
Stream = dlgSave.OpenFile()
Dim
bytes
As
[
Byte
]() = Encoding.UTF8.GetBytes(Content)
stream.Write(bytes, 0, bytes.Length)
stream.Close()
End
Using
End
If
Method2:
Dim
extension
As
String
=
""
Dim
format
As
ExportFormat = ExportFormat.Html
extension =
"xls"
format = ExportFormat.Html
Dim
dialog
As
New
SaveFileDialog()
dialog.DefaultExt = extension
dialog.Filter = [
String
].Format(
"{1} files (*.{0})|*.{0}|All files (*.*)|*.*"
, extension,
"Excel"
)
dialog.FilterIndex = 1
If
dialog.ShowDialog() =
True
Then
Using stream
As
Stream = dialog.OpenFile()
Dim
exportOptions
As
New
GridViewExportOptions()
exportOptions.Format = format
exportOptions.ShowColumnFooters =
True
exportOptions.ShowColumnHeaders =
True
exportOptions.ShowGroupFooters =
True
grdData.Export(stream, exportOptions)
End
Using
End
If
1-Aggregate/Grouping:
When im using header grouping and aggregate functions to summarized my grid. I would like to have that summarized view in my Excel. The problem is I have too much data displayed (the reason im using groupings) and I end up having all the grid rows exported...which I dont want. The worse are the aggregate totals for each group (sum, avg etc.) that are not exported. The ideal would be to export only the data that are visible....(not those folded and hidden by the groupings). With Method1, I get all the rows with no aggregate at all. With Method2, I get the same + the aggregate footer of the grid, but I also get weird code such as "[QCVG: Key=CM550FB240; ItemCount=2; HasSubgroups=False; ParentGroup=[QCVG: Key=Root; ItemCount=2; HasSubgroups=True; ParentGroup=null];];" in all columns of the last row.
2-Localizations
When im using French Canadian localization ("fr-CA"), im always getting weird characters for "special" letters (like "é", etc.) For instance the word "Équipement" becomes "Équipement". I also noted that when using {0:N4} as DataFormatString for particular numeric type columns (ex: 7,68), the export gives 76,80. Im forced to use default DataFormatString which use "." instead of "," but I lose the 4 digits limit.
Ive also attached a screenshot of the gridview (grouped and expanded) + exported .xls for each method (the first one is using french localization to demonstrate problem #2)
Can you help please?
Thanks in advance