This is a migrated thread and some comments may be shown as answers.

Export to Excel with a fixed worksheet value

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sompop
Top achievements
Rank 1
Sompop asked on 06 Feb 2012, 11:28 PM
Hi there,

The worksheet is always changed based on the file name when I try to export an excel from RadGrid. How do I make sure that the worksheet will always be "Sheet 1" regardless of file name it is?

Regards,

Below is the code for exporting.

            rg.MasterTableView.GroupByExpressions.Clear(); 
            rg.ExportSettings.ExportOnlyData = true;
            rg.ExportSettings.IgnorePaging = true;
            rg.ExportSettings.FileName = "Sheet1";// dtToday.Year.ToString() + " " + dtToday.Month.ToString() + " " + dtToday.Day.ToString() + " " + customer;
            
            if (rg.MasterTableView.Items.Count != 0) rg.MasterTableView.ExportToExcel();

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 07 Feb 2012, 05:20 AM
Hello,

Try the following code.
c#:
protected void RadGrid1_ExcelMLExportRowCreated(object sender, GridExportExcelMLRowCreatedArgs e)
{
 e.Worksheet.Name = "Sheet1";
}

-Shinu.
Tags
Grid
Asked by
Sompop
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or