This project has moved. For the latest updates, please go here.

XLTotalsRowFunction Not Working

Mar 6, 2012 at 7:28 PM

I am trying to get a totals row built in SharePoint C# webpart Excel export.  However, when I using the code below I get a #Ref! error in Excel (I commented out the section that is giving this error).  If I use the .CreateTable method instead of the .AsTable() method I get a repaired Excel error.  Am I doing something wrong or is this an issue with SharePoint and Excel export?

var table = tableRange.AsTable(); 

 table.ShowTotalsRow = true;

//table.Field(2).TotalsRowFunction = XLTotalsRowFunction.Sum;

Mar 6, 2012 at 7:29 PM

To add to code above, here is my expanded code:

 

	       var firstCell = worksheet.FirstCellUsed();
                var lastCell = worksheet.LastCellUsed();
                var tableRange = worksheet.Range(firstCell.Address, lastCell.Address);
                tableRange.Column(3).Style.NumberFormat.Format = "$ #,##0.00";
                var table = tableRange.AsTable();
                table.ShowTotalsRow = true;
                //table.Field(2).TotalsRowFunction = XLTotalsRowFunction.Sum;