Overview
This document provides an instructional guide on how to export a Historian Database into a CSV file using SQL Server Historian. This is particularly useful for retrieving older, archived data in Excel.
TheThis guide provides a line of code to be used in CodeBehind, which, upon a button click, triggers the export of data into an Excel file.
Export the Historian Database into an CSV File
To retrieve older data that has been archived using SQL Server Historian in Excel, follow the steps below:
To save the historian database to an Excel file, write the following line of code in CodeBehind and set it up so that when the button is clicked, the code is executed:
Code Block | ||
---|---|---|
| ||
public void MouseLeftButtonDown1(object sender, System.Windows.Input.InputEventArgs e)
{
var nowDate = new DateTime(2023, 7, 2, 22, 59, 59);
var startDate = new DateTime(2021, 7, 2, 22, 59, 59);
@Historian.Table.Table1.SaveToTextFile(startDate, nowDate, "HistorianFileSave", ";", true, true, false, 2, null);
} |
The result will be the data exported as follows:
To access a
projectsolution example that presents an out-of-box solution for exporting historical data to CSV files, visit
: - Export - 9.2 (LINK TO 9.2, NEED TO UPDATE THE TPROJ TO V10)In this section...
Page Tree | ||||
---|---|---|---|---|
|