C# – Add subtotals to data in a spreadsheet


I'm doing some server side excel output using the OpenXML Sdk v2 ctp. Has anyone here had any experience using this – mpre specifically:

Is there a way to add subtotals to data in a spreadsheet using the SDK? or do i need to manually iterate over the data adding the OutlineLevel property?

rows.Add(new Row(cells.ToArray()) { 
    RowIndex = (UInt32Value)Convert.ToUInt32(idx), 
    Spans = new ListValue<StringValue>() { InnerText = "1:2" }, 
    OutlineLevel = (ByteValue)groupLevelCount 

this would be a real PITA if I have to do it manually as there I need to do multi level grouping and sorting

Best Solution

Have you tried to use the document DocumentReflector included in the SDK? DocumentReflector tool can load an OpenXML document and reverse engineer the code for generating that document with the SDK. In other words, it generates C# code from an xlsx file.

The DocumentReflector tool is located in the Tools folder under the Open XML Format SDK 2.0 installation folder.

Maybe it can help to fix your issue.

Related Question