Export Excel with new Sheet and data into cells

Im trying to export to excel, with a new sheet and data written into the new sheet
Im using the 31.2.15 version which works sheet renaming

But Im unable to set the data in another WorkSheet

That is what Im trying:

protected async Task ExportarExcel(FiltroRelatorioViewModel filtro)
   {
      await JsRuntime.InvokeVoidAsync("toggleLoadingModal", true);


      ExcelExportProperties exportProperties = new ExcelExportProperties();
      exportProperties.FileName = $"Relatorio de Projetos.xlsx";
      exportProperties.IncludeTemplateColumn = true;

      // Add a new workbook to the Excel document that contains only 1 worksheet.
      exportProperties.Workbook = new Workbook();
      // Add additional worksheets.
      Console.WriteLine("Worksheets count:"+exportProperties.Workbook.Worksheets.Count());
      exportProperties.Workbook.Worksheets[0].Name = Localizer["Relatório"];
     
      var sheet2 = exportProperties.Workbook.Worksheets.Add();
      sheet2.Name = "Resumo";    

         
      Console.WriteLine("sheets row count:"+sheet2.Rows.Count());
      sheet2.Rows.Add();
      sheet2.Rows.Add();      
     
      sheet2.Rows[0].Cells.Add();
      sheet2.Rows[0].Cells.Add();
      sheet2.Rows[0].Cells.Add();
      sheet2.Rows[0].Cells[0].Value="teste";
     
      sheet2.Rows[0].Cells[1].SetValue("Teste" );
      sheet2.Rows[0].Cells[2].SetValue("Tetse" );      
     

      // Define the Gridsheet index where Grid data must be exported.
      exportProperties.GridSheetIndex = 0;
      await GridRelatorio!.ExportToExcelAsync(exportProperties);

      await JsRuntime.InvokeVoidAsync("toggleLoadingModal", false);
   }


When opening the excel I get the warning:
Image_3105_1764256299391

New sheet apperars on the document
Image_2464_1764256322168

But there is no data into them:
Image_4019_1764256358430



1 Reply

NP Naveen Palanivel Syncfusion Team December 4, 2025 07:14 AM UTC

Hi Daniel,

Thanks for patient,

We reviewed your query and understand that you want to add an extra worksheet, assign a custom name, and set values in that worksheet. However, the export does not work correctly on your end. After checking your code snippet, we found that after adding rows and cells, you need to set the Index for both the row and the cell to ensure the data exports correctly. Please refer to the following code snippet and sample for more information.


Sample : https://blazorplayground.syncfusion.com/BXVSsVtzLgbjyIAN

 

    public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)

    {

        if (args.Item.Id == "Grid_excelexport")

        {

 

            ExcelExportProperties exportProperties = new ExcelExportProperties();

            exportProperties.FileName = $"Relatorio de Projetos.xlsx";

            exportProperties.IncludeTemplateColumn = true;

            //  Add a new workbook to the Excel document that contains only 1 worksheet.

            exportProperties.Workbook = new Workbook();

 

            // Rename the first sheet (Grid data will be exported here)

            exportProperties.Workbook.Worksheets[0].Name = "Relatório";

 

            // Define the Gridsheet index where Grid data must be exported.

            exportProperties.GridSheetIndex = 0;

 

            exportProperties.Workbook.Worksheets.Add();

 

            Syncfusion.ExcelExport.Worksheet sheet2 = exportProperties.Workbook.Worksheets[1];

 

            sheet2.Name = "Resumo";

            Syncfusion.ExcelExport.Row row1 = sheet2.Rows.Add();

 

            row1.Index = 1;

            Syncfusion.ExcelExport.Cell cell1 = row1.Cells.Add();

            cell1.Index = 1;

            cell1.Value = "teste";

 

            Syncfusion.ExcelExport.Cell cell2 = row1.Cells.Add();

            cell2.Index = 2;

            cell2.Value = "Teste";

 

            Syncfusion.ExcelExport.Cell cell3 = row1.Cells.Add();

            cell3.Index = 3;

            cell3.Value = "Tetse";

 

            await Grid.ExportToExcelAsync(exportProperties);

 

        }

    }


Regards,
Naveen


Loader.
Up arrow icon