0

I've been struggling to get a handle on OpenXML and my most recent roadblock has been TotalsRows.

I've tried using combinations of the following:

            Table table = new Table
            {
                Id = tableIDIndex,
                Name = "Table" + tableIDIndex,
                DisplayName = "Table" + tableIDIndex,
                Reference = reference,
                TotalsRowCount = 1,
                TotalsRowShown = true,
                HeaderRowCount = 1
            };

and modifying TableColumns:

TableColumn nextColumn = new TableColumn()
{
    Id = currentIndex,
    Name = stringTable.SharedStringTable.ElementAt(int.Parse(nextCell.InnerText)).InnerText,
    TotalsRowFunction = TotalsRowFunctionValues.Sum
};

tableColumns.AppendChild(nextColumn);

The output I constantly create is correctly set to "Sum" within the excel cell but no data exists within. Excel Result

Any ideas or help would be appreciated, and I can provide additional example code if needed.

3
  • The following may be of interest: stackoverflow.com/a/77816338/10024425 Commented Jan 15 at 5:33
  • @Itallmakescents That definitely helped with structure, but the resulting code simply sets the text value of the totals row field and removing that line results in the same output as my initial code. I just tried adding: workbookPart1.Workbook.CalculationProperties.ForceFullCalculation = true; workbookPart1.Workbook.CalculationProperties.FullCalculationOnLoad = true; Before closing the document and this worked. Thank you for the help! Commented Jan 15 at 15:59
  • If you found the referenced post helpful, then ensure that you give it an upvote - it's how one gets paid on SO Commented Jan 15 at 16:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.