Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open xml to query excel cells

Tags:

c#

excel

openxml

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?

like image 359
Jose3d Avatar asked Feb 14 '11 21:02

Jose3d


People also ask

How do I query an XML in Excel?

You can then work with live XML data in Excel. In Excel, open the Data tab and choose From Other Sources -> From Microsoft Query. Choose the XML DSN. Select the option to use Query Wizard to create/edit queries.

Can you open XML in Excel?

Use the Open command from within Excel to open an XML data file — and then select As an XML table in the Open XML dialog box.

How do I get Excel to open XML automatically?

Follow the below steps: Open the Excel application> Open the Task Manager> Right-click on Excel in Processes tab> Open file lication> It will take you to the location where Excel.exe is present.


1 Answers

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;
    .
    .
    .
}
like image 71
Samuel Neff Avatar answered Oct 20 '22 17:10

Samuel Neff