Export to Excel "SheetName" already exists

2 posts, 0 answers
  1. Mark
    Mark avatar
    35 posts
    Member since:
    Oct 2014

    Posted 14 Oct 2015 Link to this post

    Is there something built into the export of the PivotTable to a Excel file to have to check for the name w/out throwing an error or better yet, have it auto Index it? 



  2. Ralitsa
    Ralitsa avatar
    175 posts

    Posted 19 Oct 2015 Link to this post

    Hi Mark,

    Thank you for contacting us. 

    You can create unique names of SheetName using number or date. Please refer to the code snippet below: 
    PivotGridSpreadExport exporter;
    SpreadExportRenderer exportRenderer;
    int sheetNumber;
    private void radButton1_Click(object sender, EventArgs e)
        exportRenderer = new SpreadExportRenderer();
        exporter = new PivotGridSpreadExport(this.radPivotGrid1);
        exporter.SheetName = "SpreadExport" + sheetNumber;
        exporter.ExportFormat = SpreadExportFormat.Xlsx;
        exporter.FileExportMode = FileExportMode.NewSheetInExistingFile;
        exporter.RunExport(@"..\..\file.xlsx", exportRenderer);

    Another suggestion is to set the FileExportMode property to CreateOrOverrideFile which will override the specified file and it is not necessary to create unique name of sheet each time. 

    Hope this will help you. Let me know if you have any other questions.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top