简体   繁体   中英

Open xml sdk with Excel Add In

I want to use open xml sdk in excel add-In. But

SpreadsheetDocument.Open()

method fails as the subject document is currently open.

To describe more.

I open any excel document, and have my custom excel add-in in it.from the add-in I want to gather some data from the spreadsheet using open xml sdk.

Is there any way around this, to use open xml sdk in excel add-ins and access current workbook using the same?

You can gather data from Excel using the Excel Object Model also, and is far more convenient. But as you are using Open XML SDK and calling it to open the same document again from within Excel, you should Open it as ReadOnly.

SpreadsheetDocument.Open(path, isEditable)

Set the current spreadsheet's full path in path and set isEditble to False

Get more info at MSDN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM