0

folks,

Environment

  • Windows 8.1
  • Visual Studio 2013
  • C#

Issue

How do I write values and make charts on visible Excel sheets using NPOI (https://npoi.codeplex.com/).

Why do I want that?

I'm developing an application to measure temperature in an apparatus. To put together experimental data in one place, I'd like to record data on an Excel sheet and make a chart on the sheet. In addition, I'd like to keep the Excel sheet visible and check the chart updated in real time.

You could also make graphs on Windows Form apps with MeasurementStudio by NationalInstruments for example but considering the flexibility of Excel charts (size and xy range changeable, easy-to-use user interface, etc...), I'd like to stick to Excel.

You can easily do this with Microsoft.Office.Interop.Excel by ExcelApp.visible = true;. However, this module requires users to release every COM object generated. Otherwise, the objects remain and eat up memory. This is the reason I prefer to use NPOI.

How can I achieve this? Any answers would be appreciated.

dixhom
  • 2,419
  • 4
  • 20
  • 36

1 Answers1

1

You cannot do this with NPOI. NPOI reads and writes data from serialized Excel files. You cannot access those files while Excel has them open, and even if you could, Excel simply wouldn't re-read the files so your modifications wouldn't show up.

The problem you describe comes down to "I want to interact with a running Excel instance without using Excel interop". That's not going to work.

Paul-Jan
  • 16,746
  • 1
  • 63
  • 95