#include "sierrachart.h"
SCSFExport scsf_SpreadsheetInteractionExample(SCStudyInterfaceRef sc)
{
SCSubgraphRef Subgraph_FormulaResult = sc.Subgraph[0];
if (sc.SetDefaults)
{
sc.GraphName = "Spreadsheet Interaction Example";
sc.StudyDescription
= "This is an example study for demonstrating how to interact with spreadsheets from ACSIL. This example requires an open sheet collection name \"ACSILInteractionExample\".";
sc.AutoLoop = 0;
Subgraph_FormulaResult.Name = "Formula Result";
Subgraph_FormulaResult.DrawZeros = true;
return;
}
const char* SheetCollectionName = "ACSILInteractionExample";
const char* SheetName = "Sheet1";
void* SheetHandle = sc.GetSpreadsheetSheetHandleByName(SheetCollectionName, SheetName, false);
sc.SetSheetCellAsString(SheetHandle, 0, 1, "High");
sc.SetSheetCellAsString(SheetHandle, 0, 2, "Low");
sc.SetSheetCellAsString(SheetHandle, 0, 3, "Enter Formula");
sc.SetSheetCellAsString(SheetHandle, 0, 5, "Log Message");
sc.SetSheetCellAsDouble(SheetHandle, 1, 1, sc.BaseData[SC_HIGH][sc.Index]);
sc.SetSheetCellAsDouble(SheetHandle, 1, 2, sc.BaseData[SC_LOW][sc.Index]);
double CellValue = 0.0;
sc.GetSheetCellAsDouble(SheetHandle, 1, 3, CellValue);
Subgraph_FormulaResult[sc.Index] = static_cast<float>(CellValue);
SCString CellString;
if (sc.GetSheetCellAsString(SheetHandle, 1, 5, CellString))
sc.AddMessageToLog(CellString, 0);
}