Jose3d
Jose3d

Reputation: 9277

open xml to query excel cells

In the past, I have created a component to pass and retrieve values to/from excel using the excel libraries. The good thing is that once you have your workbook in memory and modify a cell (let's call it the origin cell) all the other cells with formulas that take this origin cell value are automatically refreshed.

Is this possible in OpenXml?

As far as I see, apparently this doesn't happen in OpenXml because the excel engine is not really executed in the background, OpenXml is just a group of classes to serialize, deserialize, read etc xml files right?

Upvotes: 7

Views: 1923

Answers (1)

Samuel Neff
Samuel Neff

Reputation: 74899

That's correct, Office Open XML SDK is just a set of libraries to read/write XML files. It does not have any functionality for performing calculations.

You can specify that Excel should recalculate everything upon load by setting the following attribute, but if you need to read the new values in code (prior to re-opening in Excel) this won't help.

<workbook> 
  <calcPr fullCalcOnLoad="1"/> 
</workbook> 

Or in code with the Office Open XML SDK..

using (var doc = SpreadsheetDocument.Open(path, false))
{
    doc.WorkbookPart.Workbook.CalculationProperties.FullCalculationOnLoad = true;
    .
    .
    .
}

Upvotes: 3

Related Questions