This question is locked. New answers and comments are not allowed.
Hi,
I need to make the header text to bold while exporting Grid to excel.
In my page ,there no Grid control.
So to use export option of Grid , i have created a dynamic Grid Control and binding the data to it.
As per requirements, i need to provide show-dialog box with a default name (user can change name if he wants)
Below is my code
AuthGridView authGridView = new AuthGridView();
authGridView.AutoGenerateColumns = true;
authGridView.ItemsSource = this.searchResults;
SaveFileDialog dialog = new SaveFileDialog();
dialog.DefaultExt = "*.xls";
dialog.Filter = "Excel files (*.xls)|*.xls";
dialog.DefaultFileName = DateTime.Now.ToString("yyyyMMddHHmmss");
if (dialog.ShowDialog() == true)
{
using (Stream stream = dialog.OpenFile())
{
GridViewExportOptions exportOptions = new GridViewExportOptions();
exportOptions.Format = ExportFormat.ExcelML;
exportOptions.ShowColumnFooters = true;
exportOptions.ShowColumnHeaders = true;
exportOptions.ShowGroupFooters = true;
authGridView.Export(stream, exportOptions);
}
}
I need to make the header text to bold while exporting Grid to excel.
In my page ,there no Grid control.
So to use export option of Grid , i have created a dynamic Grid Control and binding the data to it.
As per requirements, i need to provide show-dialog box with a default name (user can change name if he wants)
Below is my code
AuthGridView authGridView = new AuthGridView();
authGridView.AutoGenerateColumns = true;
authGridView.ItemsSource = this.searchResults;
SaveFileDialog dialog = new SaveFileDialog();
dialog.DefaultExt = "*.xls";
dialog.Filter = "Excel files (*.xls)|*.xls";
dialog.DefaultFileName = DateTime.Now.ToString("yyyyMMddHHmmss");
if (dialog.ShowDialog() == true)
{
using (Stream stream = dialog.OpenFile())
{
GridViewExportOptions exportOptions = new GridViewExportOptions();
exportOptions.Format = ExportFormat.ExcelML;
exportOptions.ShowColumnFooters = true;
exportOptions.ShowColumnHeaders = true;
exportOptions.ShowGroupFooters = true;
authGridView.Export(stream, exportOptions);
}
}