C# Using data from Excel to simulate a Signal over time

点点圈 提交于 2019-12-13 02:56:59

问题


is there any good way how i can import a Excel file with signal values (40,000 values, ~100 minutes measurement time) and simulate a signal over time with it?

I want to reconstruct the simulation with timestamp and Signal values.

I've two columns:

  • Timestamp for every value (it isn't equidistant)
  • Signal-Value

The timestamp should be nearly synchron with the simulationtime.

Maybe someone has a good "to start" idea?

Thank you!

Update #1 (based on the comments):

@Wouter de Kort: I got data from measurement over time. I got for every timestamp a value. The data looks something like this (without backslash):

Time (s) // Value

154,51 // 49,33

154,71 // 49,46

154,92 // 49,72

155,11 // 49,64

I only want to look from the beginning to the end of the data over a time (the time, the measurement in real took). Like a Sinus Generator, but in this case i've a specific signal and the values has to be at a specific time.

How can i export it to CSV? And what are the benefits using CSV with C# instead of Excel?

Update #2:

My case is, to get every (e.g.) 100ms a new value through a variable which i can use for my visualization program i already have.


回答1:


Take a look at this: Importing Excel into a DataTable Quickly There's an importing example directly from an Excel spreadsheet without the need to convert to CSV.

You can also use OfficeOpenXml. It provides a way to access cell data like so:

using OfficeOpenXml;
...
var pck = new ExcelPackage(fileName);
var ws = pck.Workbook.Worksheets.ElementAt(0);  // first worksheet
ws.Select();
var value = ws.Cells[row, col].Value;           // corresponds to some Excel cell value


来源:https://stackoverflow.com/questions/48377140/c-sharp-using-data-from-excel-to-simulate-a-signal-over-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!